Exception in thread “main” java.net.BindException: Selenium is already running on port 4444.

Have you ever got the fol­low­ing error ?

18:00:45.430 INFO - Launching a standalone server
...
Exception in thread "main" java.net.BindException: Selenium is already running on port 4444. Or some other service is.
    at org.openqa.selenium.server.SeleniumServer.start(SeleniumServer.java:491)
    at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:300)
    at org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:245)
    at org.openqa.grid.selenium.GridLauncher.main(GridLauncher.java:97)

18:00:45.563 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
18:00:45.564 INFO - Version Jetty/5.1.x
18:00:45.565 INFO - Started HttpContext[/selenium-server,/selenium-server]
18:00:45.583 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@6833ce2c
18:00:45.583 INFO - Started HttpContext[/wd,/wd]
18:00:45.583 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
18:00:45.584 INFO - Started HttpContext[/,/]
18:00:45.586 WARN - Failed to start: SocketListener0@0.0.0.0:4444
Exception in thread "main" java.net.BindException: Selenium is already running on port 4444. Or some other service is.
    at org.openqa.selenium.server.SeleniumServer.start(SeleniumServer.java:491)
    at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:300)
    at org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:245)
    at org.openqa.grid.selenium.GridLauncher.main(GridLauncher.java:97)

The error says there was a process run­ning on port 4444. Hence, it can not start another process on the same port. We have to kill the process using the port 444.


Solu­tion 1 :

You can list all the run­ning processes and find the process run­ning on port 4444 then kill the process run­ning on port 4444.

lsof -i -n -P | grep 4444

sudo kill -9 <PID>

Solu­tion 2:

Another way to kill the sele­nium server is just visit the fol­low­ing url :

http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer

If sele­nium server is already run­ning on port 4444 then it will shut down the server and says OKOK if sele­nium is not run­ning on this port 4444 then by hit­ting above url will give you “Unable to connect”


You may also like...