Port not freed on stopping the appium server 2.0.1

If I stop the server with control + z then ports are not getting freed and have to kill the process manually. can this be possible other ports are also not freed?

If I restart the server then I am unable to restart it .

xxxx:~ xxxx$ appium server
[Appium] Welcome to Appium v2.0.1
[Appium] Attempting to load driver chromium…
[debug] [Appium] Requiring driver at /Users/xxxx/node_modules/appium-chromium-driver
[Appium] Appium REST http interface listener started on http://0.0.0.0:4723
[Appium] You can provide the following URLS in your client code to connect to this server:
[Appium] http://127.0.0.1:4723/ (only accessible from the same host)
[Appium] http://10.177.183.77:4723/
[Appium] Available drivers:
[Appium] - [email protected] (automationName ‘Chromium’)
[Appium] No plugins have been installed. Use the “appium plugin” command to install the one(s) you want to use.
^Z
[1]+ Stopped appium server
xxxx:~ xxxx$ appium server
[Appium] Welcome to Appium v2.0.1
[Appium] Attempting to load driver chromium…
[debug] [Appium] Requiring driver at /Users/xxxx/node_modules/appium-chromium-driver
[HTTP] Could not start REST http interface listener. The requested port may already be in use. Please make sure there is no other instance of this server running already.
[Appium] Could not configure Appium server. It’s possible that a driver or plugin tried to update the server and failed. Original error: listen EADDRINUSE: address already in use 0.0.0.0:4723
[debug] [Appium] Error: listen EADDRINUSE: address already in use 0.0.0.0:4723
[debug] [Appium] at Server.setupListenHandle [as _listen2] (node:net:1823:16)
[debug] [Appium] at listenInCluster (node:net:1871:12)
[debug] [Appium] at doListen (node:net:2020:7)
[debug] [Appium] at processTicksAndRejections (node:internal/process/task_queues:83:21)
xxxx:~ xxxx$ appium plugin
Error: :heavy_multiplication_x: Cannot handle plugin command undefined
xxxx:~ xxxx$ sudo appium plugin
Password:
Error: :heavy_multiplication_x: Cannot handle plugin command undefined
xxxx:~ xxxx$ appium server
[Appium] Welcome to Appium v2.0.1
[Appium] Attempting to load driver chromium…
[debug] [Appium] Requiring driver at /Users/xxxx/node_modules/appium-chromium-driver
[HTTP] Could not start REST http interface listener. The requested port may already be in use. Please make sure there is no other instance of this server running already.
[Appium] Could not configure Appium server. It’s possible that a driver or plugin tried to update the server and failed. Original error: listen EADDRINUSE: address already in use 0.0.0.0:4723
[debug] [Appium] Error: listen EADDRINUSE: address already in use 0.0.0.0:4723
[debug] [Appium] at Server.setupListenHandle [as _listen2] (node:net:1823:16)
[debug] [Appium] at listenInCluster (node:net:1871:12)
[debug] [Appium] at doListen (node:net:2020:7)
[debug] [Appium] at processTicksAndRejections (node:internal/process/task_queues:83:21)
xxxx:~ xxxx$ sudo lsof -i :4723
Password:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 64533 xxxx 24u IPv4 0x932b5bb6906e7dcf 0t0 TCP *:4723 (LISTEN)
xxxx:~ xxxx$ sudo kill -9 64533
xxxx:~xxxx$

When you send a process to the background with ‘control z’ it will pause itself. This is just normal behavior. You cannot resume the process again by starting a new instance. You need to use the command, ‘fg’ (foreground) to foreground the app and resume running.

This is general info for any process, not Appium specific. You could also use ‘bg’ (background) to start the process in the background, but I don’t think that’s what you want. More info here:

https://www.garron.me/en/go2linux/ctrl-z-stop-restart-linux-jobs.html

I don’t think this fg , and bg command with appium running together I have tried and mentioned in the logs. but is there any simplified way to shut down the server and restart the server without killing a process using port number?

xxxx:~ xxxx$ sudo lsof -i :4723
Password:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 64533 adityann 24u IPv4 0x932b5bb6906e7dcf 0t0 TCP *:4723 (LISTEN)
xxxx:~ xxxx$ sudo kill -9 64533
xxxx:~ xxxx$ appium
[Appium] Welcome to Appium v2.0.1
[Appium] Attempting to load driver chromium…
[debug] [Appium] Requiring driver at /Users/adityann/node_modules/appium-chromium-driver
[Appium] Appium REST http interface listener started on http://0.0.0.0:4723
[Appium] You can provide the following URLS in your client code to connect to this server:
[Appium] http://127.0.0.1:4723/ (only accessible from the same host)
[Appium] http://10.177.183.77:4723/
[Appium] Available drivers:
[Appium] - [email protected] (automationName ‘Chromium’)
[Appium] No plugins have been installed. Use the “appium plugin” command to install the one(s) you want to use.
^Z[1] Killed: 9 appium server

[2]+ Stopped appium
xxxx:~ xxxxx$ appium fg

[ERROR] Unrecognized arguments: fg
xxxx:~ xxxxx$ appium &
[3] 97638
xxxx:~ xxxx$ [Appium] Welcome to Appium v2.0.1
[Appium] Attempting to load driver chromium…
[debug] [Appium] Requiring driver at /Users/adityann/node_modules/appium-chromium-driver
[HTTP] Could not start REST http interface listener. The requested port may already be in use. Please make sure there is no other instance of this server running already.
[Appium] Could not configure Appium server. It’s possible that a driver or plugin tried to update the server and failed. Original error: listen EADDRINUSE: address already in use 0.0.0.0:4723
[debug] [Appium] Error: listen EADDRINUSE: address already in use 0.0.0.0:4723
[debug] [Appium] at Server.setupListenHandle [as _listen2] (node:net:1823:16)
[debug] [Appium] at listenInCluster (node:net:1871:12)
[debug] [Appium] at doListen (node:net:2020:7)
[debug] [Appium] at processTicksAndRejections (node:internal/process/task_queues:83:21)
xxxx:~ xxxx$ appium fg

[ERROR] Unrecognized arguments: fg
[3]- Exit 1 appium
xxxx:~ xxxx$ appium
[Appium] Welcome to Appium v2.0.1
[Appium] Attempting to load driver chromium…
[debug] [Appium] Requiring driver at /Users/adityann/node_modules/appium-chromium-driver
[HTTP] Could not start REST http interface listener. The requested port may already be in use. Please make sure there is no other instance of this server running already.
[Appium] Could not configure Appium server. It’s possible that a driver or plugin tried to update the server and failed. Original error: listen EADDRINUSE: address already in use 0.0.0.0:4723
[debug] [Appium] Error: listen EADDRINUSE: address already in use 0.0.0.0:4723
[debug] [Appium] at Server.setupListenHandle [as _listen2] (node:net:1823:16)
[debug] [Appium] at listenInCluster (node:net:1871:12)
[debug] [Appium] at doListen (node:net:2020:7)
[debug] [Appium] at processTicksAndRejections (node:internal/process/task_queues:83:21)
INGUR1M0465:~ adityann$ jobs
[2]+ Stopped appium
xxxx:~ xxxx$ appium bg

[ERROR] Unrecognized arguments: bg
xxxx:~ xxxx$ appium --bg

[ERROR] Unrecognized arguments: --bg
xxxx:~ xxxx$ appium -bg

[ERROR] Unrecognized arguments: -bg
xxxx:~ xxxx$ appium --help
usage: appium [-h] [-v] {server,driver,plugin} …

A webdriver-compatible server that facilitates automation of web, mobile, and other types of apps across various platforms.

positional arguments:
{server,driver,plugin}
server Run an Appium server
driver Access the driver management CLI commands
plugin Access the plugin management CLI commands

optional arguments:
-h, --help show this help message and exit
-v, --version show program’s version number and exit
xxxx:~ xxxx$ appium -h
usage: appium [-h] [-v] {server,driver,plugin} …

A webdriver-compatible server that facilitates automation of web, mobile, and other types of apps across various platforms.

positional arguments:
{server,driver,plugin}
server Run an Appium server
driver Access the driver management CLI commands
plugin Access the plugin management CLI commands

optional arguments:
-h, --help show this help message and exit
-v, --version show program’s version number and exit
xxxx:~ xxxx$ appium -bg

[ERROR] Unrecognized arguments: -bg
xxxx:~ xxxx$ appium
[Appium] Welcome to Appium v2.0.1
[Appium] Attempting to load driver chromium…
[debug] [Appium] Requiring driver at /Users/adityann/node_modules/appium-chromium-driver
[HTTP] Could not start REST http interface listener. The requested port may already be in use. Please make sure there is no other instance of this server running already.
[Appium] Could not configure Appium server. It’s possible that a driver or plugin tried to update the server and failed. Original error: listen EADDRINUSE: address already in use 0.0.0.0:4723
[debug] [Appium] Error: listen EADDRINUSE: address already in use 0.0.0.0:4723
[debug] [Appium] at Server.setupListenHandle [as _listen2] (node:net:1823:16)
[debug] [Appium] at listenInCluster (node:net:1871:12)
[debug] [Appium] at doListen (node:net:2020:7)
[debug] [Appium] at processTicksAndRejections (node:internal/process/task_queues:83:21)
xxxx:~ xxxx$ appium -fg

[ERROR] Unrecognized arguments: -fg
xxxx:~ xxxx$ appium --fg

[ERROR] Unrecognized arguments: --fg
xxxx:~ xxxx$

Sure, here are a number of ways to do so:

control + c
pkill -9 -f appium
killall -KILL node

You may eventually find it easier to stop the Appium server from your code. This is a good place to find such info:

1 Like