selenium-standalone icon indicating copy to clipboard operation
selenium-standalone copied to clipboard

Java.net.BindException: Selenium is already running on port 4444. Or some other service is.

Open djom202 opened this issue 10 years ago • 3 comments

When I try run my test.

selenium-standalone start

10:51:37.031 INFO - Launching a standalone Selenium Server Setting system property webdriver.chrome.driver to /usr/local/lib/node_modules/selenium-standalone/.selenium/chromedriver/2.21-x64-chromedriver 10:51:37.071 INFO - Java: Oracle Corporation 25.74-b02 10:51:37.072 INFO - OS: Mac OS X 10.11.3 x86_64 10:51:37.083 INFO - v2.53.0, with Core v2.53.0. Built from revision 35ae25b 10:51:37.160 INFO - Driver provider org.openqa.selenium.ie.InternetExplorerDriver registration is skipped: registration capabilities Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}] does not match the current platform MAC 10:51:37.160 INFO - Driver provider org.openqa.selenium.edge.EdgeDriver registration is skipped: registration capabilities Capabilities [{browserName=MicrosoftEdge, version=, platform=WINDOWS}] does not match the current platform MAC 10:51:37.161 INFO - Driver class not found: com.opera.core.systems.OperaDriver 10:51:37.161 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered 10:51:37.163 INFO - Driver class not found: org.openqa.selenium.htmlunit.HtmlUnitDriver 10:51:37.163 INFO - Driver provider org.openqa.selenium.htmlunit.HtmlUnitDriver is not registered 10:51:37.249 WARN - Failed to start: [email protected]:4444


Running as a standalone server:

Usage: java -jar selenium-server.jar [-interactive] [options]

-port : the port number the selenium server should use (default 4444) -timeout : an integer number of seconds we should allow a client to be idle -browserTimeout : an integer number of seconds a browser is allowed to hang -interactive: puts you into interactive mode. See the tutorial for more details -singleWindow: puts you into a mode where the test web site executes in a frame. This mode should only be selected if the application under test does not use frames. -profilesLocation: Specifies the directory that holds the profiles that java clients can use to start up selenium. Currently supported for Firefox only. -forcedBrowserMode : sets the browser mode to a single argument (e.g. "_iexplore") for all sessions, no matter what is passed to getNewBrowserSession -forcedBrowserModeRestOfLine : sets the browser mode to all the remaining tokens on the line (e.g. "_custom /some/random/place/iexplore.exe") for all sessions, no matter what is passed to getNewBrowserSession -userExtensions : indicates a JavaScript file that will be loaded into selenium -browserSessionReuse: stops re-initialization and spawning of the browser between tests -avoidProxy: By default, we proxy every browser request; set this flag to make the browser use our proxy only for URLs containing '/selenium-server' -firefoxProfileTemplate

: normally, we generate a fresh empty Firefox profile every time we launch. You can specify a directory to make us copy your profile directory instead. -debug: puts you into debug mode, with more trace information and diagnostics on the console -browserSideLog: enables logging on the browser side; logging messages will be transmitted to the server. This can affect performance. -ensureCleanSession: If the browser does not have user profiles, make sure every new session has no artifacts from previous sessions. For example, enabling this option will cause all user cookies to be archived before launching IE, and restored after IE is closed. -trustAllSSLCertificates: Forces the Selenium proxy to trust all SSL certificates. This doesn't work in browsers that don't use the Selenium proxy. -log : writes lots of debug information out to a log file and disables logging to console -logLongForm: writes information out to console in long format (for debugging purpose) -htmlSuite : Run a single HTML Selenese (Selenium Core) suite and then exit immediately, using the specified browser (e.g. "*firefox") on the specified URL (e.g. "http://www.google.com"). You need to specify the absolute path to the HTML test suite as well as the path to the HTML results file we'll generate. -proxyInjectionMode: puts you into proxy injection mode, a mode where the selenium server acts as a proxy server for all content going to the test application. Under this mode, multiple domains can be visited, and the following additional flags are supported:

-dontInjectRegex <regex>: an optional regular expression that
  proxy injection mode can use to know when to bypss injection
-userJsInjection <file>: specifies a JavaScript file which will
  then be injected into all pages
-userContentTransformation <regex> <replacement>: a regular
  expression which is matched against all test HTML content; the
  second is a string which will replace matches.  These flags can
  be used any number of times.  A simple example of how this could
  be useful: if you add "-userContentTransformation https http"
  then all "https" strings in the HTML of the test application will
  be changed to be "http".

This synopsis lists options available in standalone role only. To get help on the options available for other roles run the server with -help option and the corresponding -role option value. 10:51:37.031 INFO - Launching a standalone Selenium Server Setting system property webdriver.chrome.driver to /usr/local/lib/node_modules/selenium-standalone/.selenium/chromedriver/2.21-x64-chromedriver 10:51:37.071 INFO - Java: Oracle Corporation 25.74-b02 10:51:37.072 INFO - OS: Mac OS X 10.11.3 x86_64 10:51:37.083 INFO - v2.53.0, with Core v2.53.0. Built from revision 35ae25b 10:51:37.160 INFO - Driver provider org.openqa.selenium.ie.InternetExplorerDriver registration is skipped: registration capabilities Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}] does not match the current platform MAC 10:51:37.160 INFO - Driver provider org.openqa.selenium.edge.EdgeDriver registration is skipped: registration capabilities Capabilities [{browserName=MicrosoftEdge, version=, platform=WINDOWS}] does not match the current platform MAC 10:51:37.161 INFO - Driver class not found: com.opera.core.systems.OperaDriver 10:51:37.161 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered 10:51:37.163 INFO - Driver class not found: org.openqa.selenium.htmlunit.HtmlUnitDriver 10:51:37.163 INFO - Driver provider org.openqa.selenium.htmlunit.HtmlUnitDriver is not registered 10:51:37.249 WARN - Failed to start: [email protected]:4444


Running as a standalone server:

Usage: java -jar selenium-server.jar [-interactive] [options]

-port : the port number the selenium server should use (default 4444) -timeout : an integer number of seconds we should allow a client to be idle -browserTimeout : an integer number of seconds a browser is allowed to hang -interactive: puts you into interactive mode. See the tutorial for more details -singleWindow: puts you into a mode where the test web site executes in a frame. This mode should only be selected if the application under test does not use frames. -profilesLocation: Specifies the directory that holds the profiles that java clients can use to start up selenium. Currently supported for Firefox only. -forcedBrowserMode : sets the browser mode to a single argument (e.g. "_iexplore") for all sessions, no matter what is passed to getNewBrowserSession -forcedBrowserModeRestOfLine : sets the browser mode to all the remaining tokens on the line (e.g. "_custom /some/random/place/iexplore.exe") for all sessions, no matter what is passed to getNewBrowserSession -userExtensions : indicates a JavaScript file that will be loaded into selenium -browserSessionReuse: stops re-initialization and spawning of the browser between tests -avoidProxy: By default, we proxy every browser request; set this flag to make the browser use our proxy only for URLs containing '/selenium-server' -firefoxProfileTemplate

: normally, we generate a fresh empty Firefox profile every time we launch. You can specify a directory to make us copy your profile directory instead. -debug: puts you into debug mode, with more trace information and diagnostics on the console -browserSideLog: enables logging on the browser side; logging messages will be transmitted to the server. This can affect performance. -ensureCleanSession: If the browser does not have user profiles, make sure every new session has no artifacts from previous sessions. For example, enabling this option will cause all user cookies to be archived before launching IE, and restored after IE is closed. -trustAllSSLCertificates: Forces the Selenium proxy to trust all SSL certificates. This doesn't work in browsers that don't use the Selenium proxy. -log : writes lots of debug information out to a log file and disables logging to console -logLongForm: writes information out to console in long format (for debugging purpose) -htmlSuite : Run a single HTML Selenese (Selenium Core) suite and then exit immediately, using the specified browser (e.g. "*firefox") on the specified URL (e.g. "http://www.google.com"). You need to specify the absolute path to the HTML test suite as well as the path to the HTML results file we'll generate. -proxyInjectionMode: puts you into proxy injection mode, a mode where the selenium server acts as a proxy server for all content going to the test application. Under this mode, multiple domains can be visited, and the following additional flags are supported:

-dontInjectRegex <regex>: an optional regular expression that
  proxy injection mode can use to know when to bypss injection
-userJsInjection <file>: specifies a JavaScript file which will
  then be injected into all pages
-userContentTransformation <regex> <replacement>: a regular
  expression which is matched against all test HTML content; the
  second is a string which will replace matches.  These flags can
  be used any number of times.  A simple example of how this could
  be useful: if you add "-userContentTransformation https http"
  then all "https" strings in the HTML of the test application will
  be changed to be "http".

This synopsis lists options available in standalone role only. To get help on the options available for other roles run the server with -help option and the corresponding -role option value. java.net.BindException: Selenium is already running on port 4444. Or some other service is. at org.openqa.selenium.server.SeleniumServer.start(SeleniumServer.java:509) at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:321) at org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:240) at org.openqa.grid.selenium.GridLauncher$1.launch(GridLauncher.java:58) at org.openqa.grid.selenium.GridLauncher.main(GridLauncher.java:127) /usr/local/lib/node_modules/selenium-standalone/bin/selenium-standalone:61 throw err; ^

Error: Selenium exited before it could start at ChildProcess.errorIfNeverStarted (/usr/local/lib/node_modules/selenium-standalone/lib/start.js:123:15) at emitTwo (events.js:87:13) at ChildProcess.emit (events.js:172:7) at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12) at org.openqa.selenium.server.SeleniumServer.start(SeleniumServer.java:509) at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:321) at org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:240) at org.openqa.grid.selenium.GridLauncher$1.launch(GridLauncher.java:58) at org.openqa.grid.selenium.GridLauncher.main(GridLauncher.java:127) /usr/local/lib/node_modules/selenium-standalone/bin/selenium-standalone:61 throw err; ^

Error: Selenium exited before it could start at ChildProcess.errorIfNeverStarted (/usr/local/lib/node_modules/selenium-standalone/lib/start.js:123:15) at emitTwo (events.js:87:13) at ChildProcess.emit (events.js:172:7) at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)

djom202 avatar Apr 05 '16 16:04 djom202

Sounds like another process is already using the default port 4444. What shows when you use lsof?

$ lsof -iTCP:4444 -sTCP:LISTEN
COMMAND   PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
java    68351 sash   27u  IPv6 0x9f7c11046a64cdbd      0t0  TCP *:krb524 (LISTEN)

$ ps aux | grep 68351
sash            68400   0.0  0.0  2432772    676 s003  S+    9:34AM   0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn 68351
sash            68351   0.0  0.4  8275932  73444 s000  S+    9:34AM   0:00.98 java -jar /usr/local/lib/node_modules/selenium-standalone/.selenium/selenium-server/2.48.2-server.jar -Dwebdriver.chrome.driver=/usr/local/lib/node_modules/selenium-standalone/.selenium/chromedriver/2.20-x64-chromedriver

You can also specify a different port to start with to get around collisions:

$ selenium-standalone start -- -port 4445
09:30:43.993 INFO - Launching a standalone Selenium Server
Setting system property webdriver.chrome.driver to /usr/local/lib/selenium-standalone/.selenium/chromedriver/2.20-x64-chromedriver
09:30:44.028 INFO - Java: Oracle Corporation 25.45-b02
09:30:44.028 INFO - OS: Mac OS X 10.10.5 x86_64
09:30:44.038 INFO - v2.48.0, with Core v2.48.0. Built from revision 41bccdd
09:30:44.099 INFO - Driver provider org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}] does not match the current platform MAC
09:30:44.099 INFO - Driver provider org.openqa.selenium.edge.EdgeDriver registration is skipped:
registration capabilities Capabilities [{browserName=MicrosoftEdge, version=, platform=WINDOWS}] does not match the current platform MAC
09:30:44.099 INFO - Driver class not found: com.opera.core.systems.OperaDriver
09:30:44.099 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
09:30:44.182 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4445/wd/hub
09:30:44.182 INFO - Selenium Server is up and running
Selenium started

stephenash avatar Apr 05 '16 16:04 stephenash

We are seeing the same exact problem as above. When we run the lsof command suggested, nothing is returned.

elenasharma avatar Jan 16 '17 21:01 elenasharma

There are already multiple issues about this and somewhere someone must have found something, did you had a look at previous issues?

vvo avatar Jan 17 '17 20:01 vvo