# Port not freed on stopping the appium server 2.0.1

**URL:** <https://discuss.appium.io/t/port-not-freed-on-stopping-the-appium-server-2-0-1/39790>\
**Category:** Issues/Bugs\
**Created:** [July 27, 2023, 11:39am UTC](https://discuss.appium.io/t/port-not-freed-on-stopping-the-appium-server-2-0-1/39790 "2023-07-27T11:39:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aditya\_Anand2](https://discuss.appium.io/user_avatar/discuss.appium.io/aditya_anand2/32/11479_2.png) [@Aditya\_Anand2](https://discuss.appium.io/u/Aditya_Anand2)\
**Post date:** [July 27, 2023, 11:39am UTC](https://discuss.appium.io/t/port-not-freed-on-stopping-the-appium-server-2-0-1/39790/1 "2023-07-27T11:39:38Z")

</div>

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](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/](http://127.0.0.1:4723/) (only accessible from the same host)  
[Appium] [http://10.177.183.77:4723/](http://10.177.183.77:4723/)  
[Appium] Available drivers:  
[Appium] - chromium@1.1.20 (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: ✖ Cannot handle plugin command undefined  
xxxx:~ xxxx$ sudo appium plugin  
Password:  
Error: ✖ 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$

---

<div class="post-metadata">

**Author:** ![wreed](https://discuss.appium.io/letter_avatar_proxy/v4/letter/w/919ad9/32.png) [@wreed](https://discuss.appium.io/u/wreed)\
**Post date:** [July 27, 2023, 3:58pm UTC](https://discuss.appium.io/t/port-not-freed-on-stopping-the-appium-server-2-0-1/39790/2 "2023-07-27T15:58:16Z")

</div>

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](https://www.garron.me/en/go2linux/ctrl-z-stop-restart-linux-jobs.html)

---

<div class="post-metadata">

**Author:** ![Aditya\_Anand2](https://discuss.appium.io/user_avatar/discuss.appium.io/aditya_anand2/32/11479_2.png) [@Aditya\_Anand2](https://discuss.appium.io/u/Aditya_Anand2)\
**Post date:** [July 28, 2023, 6:08am UTC](https://discuss.appium.io/t/port-not-freed-on-stopping-the-appium-server-2-0-1/39790/3 "2023-07-28T06:08:22Z")

</div>

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](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/](http://127.0.0.1:4723/) (only accessible from the same host)  
[Appium] [http://10.177.183.77:4723/](http://10.177.183.77:4723/)  
[Appium] Available drivers:  
[Appium] - chromium@1.1.20 (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$

---

<div class="post-metadata">

**Author:** ![wreed](https://discuss.appium.io/letter_avatar_proxy/v4/letter/w/919ad9/32.png) [@wreed](https://discuss.appium.io/u/wreed)\
**Post date:** [July 28, 2023, 3:49pm UTC](https://discuss.appium.io/t/port-not-freed-on-stopping-the-appium-server-2-0-1/39790/4 "2023-07-28T15:49:57Z")

</div>

> [@Aditya\_Anand2](#):
>
> is there any simplified way to shut down the server and restart the server without killing a process using port number?

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:

> [@Launching and stopping appium server programmtically](https://discuss.appium.io/t/launching-and-stopping-appium-server-programmtically/700/2):
>
> [Update] For a complete updated guide with code example, please refer to [this](https://www.linkedin.com/pulse/startstop-appium-server-programmatically-using-java-hassan-radi). @karthik_holla I am gonna use Java and Windows to help explain that to you, you can use the equivalent of that in your preferred language/OS: To start Appium server programmatically, you need the following: Command executor tool (I prefer the second approach as it will handle most of the OS specific problems on your behalf): Java’s built-in [Process](http://docs.oracle.com/javase/7/docs/api/java/lang/Process.html) class. [Apache Commons Exec](http://commons.apache.org/proper/commons-exec/). Tell the tool what program you n…
