{"action":"created","issue":{"url":"https://api.github.com/repos/SeleniumHQ/selenium/issues/1630","repository_url":"https://api.github.com/repos/SeleniumHQ/selenium","labels_url":"https://api.github.com/repos/SeleniumHQ/selenium/issues/1630/labels{/name}","comments_url":"https://api.github.com/repos/SeleniumHQ/selenium/issues/1630/comments","events_url":"https://api.github.com/repos/SeleniumHQ/selenium/issues/1630/events","html_url":"https://github.com/SeleniumHQ/selenium/issues/1630","id":133283964,"number":1630,"title":"\"Exception: Unable to find a free port\" - SeGrid/Python/Chromedriver/Ubuntu+OSX","user":{"login":"benhastings","id":3485854,"avatar_url":"https://avatars.githubusercontent.com/u/3485854?v=3","gravatar_id":"","url":"https://api.github.com/users/benhastings","html_url":"https://github.com/benhastings","followers_url":"https://api.github.com/users/benhastings/followers","following_url":"https://api.github.com/users/benhastings/following{/other_user}","gists_url":"https://api.github.com/users/benhastings/gists{/gist_id}","starred_url":"https://api.github.com/users/benhastings/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benhastings/subscriptions","organizations_url":"https://api.github.com/users/benhastings/orgs","repos_url":"https://api.github.com/users/benhastings/repos","events_url":"https://api.github.com/users/benhastings/events{/privacy}","received_events_url":"https://api.github.com/users/benhastings/received_events","type":"User","site_admin":false},"labels":[{"id":182509154,"url":"https://api.github.com/repos/SeleniumHQ/selenium/labels/C-java","name":"C-java","color":"fbca04","default":false},{"id":182503854,"url":"https://api.github.com/repos/SeleniumHQ/selenium/labels/C-py","name":"C-py","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-02-12T16:28:51Z","updated_at":"2016-10-28T13:39:14Z","closed_at":null,"body":"**Short Description:**\r\non attempting to execute parallel tests on a host using selenium grid, the server-standalone hub accepts the first session and rejects all subsequent requests to create a session until the first terminates.\r\n\r\n**Longer Description:**\r\nI am not a java developer, so I can only dig so deeply, but it does look like something is not being correctly executed in the PortProber.java class.  However, it may be something to do with the python requests to create a new session.  I spent some time digging into the python code and wasn't able to find a way to force a particular port be requested for the new session.\r\n\r\nWe're trying to run multiple scripts on a headless virtual.  This pattern has worked previously, but we needed to make updates to our chrome version, so we went ahead and updated the selenium-standalone version (I've tried 2.49-2.52), chromedriver (2.20-2.21), and Chrome (48.0.2564.82).  In fact, in developing the python test script, I was able to run 4 sessions simultaneously on my OSX laptop.  That is no longer the case (server standalone 2.50/2.52 tried - 2.50 previously worked)\r\n\r\nI did try the selenium-server-standalone + a quick webdriver.io (nodeJS) script and it appears to work on my laptop.\r\n\r\n**Script to recreate:**\r\n(start one instance, then start another on the same system)\r\n\r\n```python\r\n#test.py\r\nfrom selenium import webdriver\r\nimport time\r\n\r\nbaseURL='http://www.yahoo.com'\r\nurl2='http://www.bing.com'\r\n\r\noptions=webdriver.ChromeOptions()\r\noptions.add_argument('--disable-logging')\r\ndriver=webdriver.Remote(desired_capabilities=options.to_capabilities())\r\n\r\ndriver.get(baseURL)\r\ntime.sleep(2.5)\r\nprint(driver.title)\r\n\r\ndriver.get(url2)\r\ntime.sleep(2.5)\r\nprint(driver.title)\r\n\r\ndriver.get(baseURL)\r\ntime.sleep(2.5)\r\nprint(driver.title)\r\n\r\ndriver.get(url2)\r\ntime.sleep(2.5)\r\nprint(driver.title)\r\n\r\ndriver.close()\r\ndriver.quit()\r\n```\r\n\r\n**Python Script Error:**\r\n```\r\n>>>python test.py\r\nTraceback (most recent call last):\r\n  File \"test.py\", line 11, in <module>\r\n    driver=webdriver.Remote(desired_capabilities=options.to_capabilities())\r\n  File \"/usr/local/lib/python2.7/dist-packages/selenium-2.51.1-py2.7.egg/selenium/webdriver/remote/webdriver.py\", line 87, in __init__\r\n    self.start_session(desired_capabilities, browser_profile)\r\n  File \"/usr/local/lib/python2.7/dist-packages/selenium-2.51.1-py2.7.egg/selenium/webdriver/remote/webdriver.py\", line 141, in start_session\r\n    'desiredCapabilities': desired_capabilities,\r\n  File \"/usr/local/lib/python2.7/dist-packages/selenium-2.51.1-py2.7.egg/selenium/webdriver/remote/webdriver.py\", line 201, in execute\r\n    self.error_handler.check_response(response)\r\n  File \"/usr/local/lib/python2.7/dist-packages/selenium-2.51.1-py2.7.egg/selenium/webdriver/remote/errorhandler.py\", line 193, in check_response\r\n    raise exception_class(message, screen, stacktrace)\r\nselenium.common.exceptions.WebDriverException: Message: Unable to find a free port\r\n```\r\n\r\n**selenium-standalone-server error output:**\r\n```\r\n10:59:41.649 INFO - Executing: [new session: Capabilities [{platform=ANY, javascriptEnabled=true, browserName=chrome, chromeOptions={args=[--disable-logging], extensions=[]}, version=}]])\r\n10:59:41.650 INFO - Creating a new session for Capabilities [{platform=ANY, javascriptEnabled=true, browserName=chrome, chromeOptions={args=[--disable-logging], extensions=[]}, version=}]\r\n10:59:41.652 WARN - Exception thrown\r\njava.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException\r\nBuild info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:06:42'\r\nSystem info: host: '**************', ip: '************', os.name: 'Linux', os.arch: 'amd64', os.version: '3.16.0-43-generic', java.version: '1.7.0_91'\r\nDriver info: driver.version: unknown\r\n  at java.util.concurrent.FutureTask.report(FutureTask.java:122)\r\n  at java.util.concurrent.FutureTask.get(FutureTask.java:188)\r\n  at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:183)\r\n  at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSession.java:119)\r\n  at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:95)\r\n  at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:124)\r\n  at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:59)\r\n  at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:1)\r\n  at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:111)\r\n  at org.openqa.selenium.remote.server.JsonHttpCommandHandler.handleRequest(JsonHttpCommandHandler.java:79)\r\n  at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:202)\r\n  at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:164)\r\n  at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)\r\n  at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet.java:130)\r\n  at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)\r\n  at org.openqa.jetty.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)\r\n  at org.openqa.jetty.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:680)\r\n  at org.openqa.jetty.jetty.servlet.ServletHandler.handle(ServletHandler.java:571)\r\n  at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1526)\r\n  at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1479)\r\n  at org.openqa.jetty.http.HttpServer.service(HttpServer.java:920)\r\n  at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)\r\n  at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986)\r\n  at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)\r\n  at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:243)\r\n  at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:358)\r\n  at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:537)\r\nCaused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException\r\nBuild info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:06:42'\r\nSystem info: host: '**********', ip: '**********', os.name: 'Linux', os.arch: 'amd64', os.version: '3.16.0-43-generic', java.version: '1.7.0_91'\r\nDriver info: driver.version: unknown\r\n  at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:113)\r\n  at org.openqa.selenium.remote.server.DefaultDriverProvider.newInstance(DefaultDriverProvider.java:97)\r\n  at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:60)\r\n  at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:222)\r\n  at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:1)\r\n  at java.util.concurrent.FutureTask.run(FutureTask.java:262)\r\n  at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)\r\n  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)\r\n  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)\r\n  at java.lang.Thread.run(Thread.java:745)\r\nCaused by: java.lang.reflect.InvocationTargetException\r\n  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)\r\n  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)\r\n  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)\r\n  at java.lang.reflect.Constructor.newInstance(Constructor.java:526)\r\n  at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:103)\r\n  ... 9 more\r\nCaused by: java.lang.RuntimeException: Unable to find a free port\r\n  at org.openqa.selenium.net.PortProber.findFreePort(PortProber.java:67)\r\n  at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:292)\r\n  at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)\r\n  at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:138)\r\n  ... 14 more\r\n10:59:41.658 WARN - Exception: Unable to find a free port\r\n```"},"comment":{"url":"https://api.github.com/repos/SeleniumHQ/selenium/issues/comments/256922339","html_url":"https://github.com/SeleniumHQ/selenium/issues/1630#issuecomment-256922339","issue_url":"https://api.github.com/repos/SeleniumHQ/selenium/issues/1630","id":256922339,"user":{"login":"visionscaper","id":1189068,"avatar_url":"https://avatars.githubusercontent.com/u/1189068?v=3","gravatar_id":"","url":"https://api.github.com/users/visionscaper","html_url":"https://github.com/visionscaper","followers_url":"https://api.github.com/users/visionscaper/followers","following_url":"https://api.github.com/users/visionscaper/following{/other_user}","gists_url":"https://api.github.com/users/visionscaper/gists{/gist_id}","starred_url":"https://api.github.com/users/visionscaper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/visionscaper/subscriptions","organizations_url":"https://api.github.com/users/visionscaper/orgs","repos_url":"https://api.github.com/users/visionscaper/repos","events_url":"https://api.github.com/users/visionscaper/events{/privacy}","received_events_url":"https://api.github.com/users/visionscaper/received_events","type":"User","site_admin":false},"created_at":"2016-10-28T13:39:14Z","updated_at":"2016-10-28T13:39:14Z","body":"I had exactly the same exception in the selenium-standalone-server error output. It turned out that I had statements in my /etc/hosts file that I had to remove (or comment out), e.g.\r\n\r\n    127.0.0.1 my-site.local\r\n\r\n    ...\r\n\r\n    192.168.100.48 localhost   \r\n"}}
{"actor":{"display_login":"visionscaper"}}