Search code examples
javaappiumappium-android

Appium Question. If "listen eaddrinuse: address already in use", how to stop it? why it didn't stop?


I had been started Appium using default 0.0.0.0:4723 address and port, but then I got this error:

C:\User\me>appium
[Appium] Welcome to Appium v1.17.0
[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.
Fatal Error: listen EADDRINUSE: address already in use 0.0.0.0:4723
    at Server.setupListenHandle [as _listen2] (net.js:1309:16)
    at listenInCluster (net.js:1357:12)
    at doListen (net.js:1496:7)
    at processTicksAndRejections (internal/process/task_queues.js:85:21)

I found that I can change the port using: appium -p 4724

I also found that I can close connection to 0.0.0.0:4723, if any, whether on the Appium desktop app or a second CMD. I closed Appium desktop app, I stopped and closed any other CMD, but I still got the same Fatal Error: listen EADDRINUSE: address already in use 0.0.0.0:4723

Then my questions: How to stop this already used address? and, Why it didn't stop?

I am ok with using another port to start my server, but shouldn't I be able to simply stop the connection to 4723 port and using it again?


Solution

  • Open a CMD window in Administrator mode by navigating to Start > Run > type cmd > right-click Command Prompt, then select Run as administrator.

    C:\Users\admin>netstat -ano|findstr "PID :4723" 
    Proto Local Address Foreign Address State PID 
    TCP 0.0.0.0:4723 0.0.0.0:0 LISTENING 6134
    

    To kill the process type the PID of the port you want to kill (which will be displayed on the CMD screen) [/f is force]

    taskkill /pid 6134 /f