• 0

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

Have you ever got the following 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: [email protected]: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 running on port 4444. Hence, it can not start another process on the same port. We have to kill the process using the port 444.

Solution 1 :

You can list all the running processes and find the process running on port 4444 then kill the process running on port 4444.
lsof -i -n -P | grep 4444

sudo kill -9 <PID>

Solution 2:

Another way to kill the selenium server is just visit the following url : http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer If selenium server is already running on port 4444 then it will shut down the server and says OKOK if selenium is not running on this port 4444 then by hitting above url will give you "Unable to connect"