title: org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: Could not start a new session
body: <p>I like to run a selenium java test in a docker container. I was able to pull chrome image and created docker containers just fine. Then I configured remote webdriver by pointing to localhost of docker port. When I run the testNG test, I get the below error.</p>
  <blockquote>
  <p>org.openqa.selenium.SessionNotCreatedException: Could not start a new
  session. Response code 500. Message: Could not start a new session.
  Error while creating session with the driver service. Stopping driver
  service: Could not start a new session. Response code 500. Message:
  unknown error: Chrome failed to start: crashed.   (unknown error:
  DevToolsActivePort file doesn't exist)   (The process started from
  chrome location /usr/bin/google-chrome is no longer running, so
  ChromeDriver is assuming that Chrome has crashed.)</p>
  </blockquote>
  <p>POM.xml</p>
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.seleniumhq.selenium&lt;/groupId&gt;
      &lt;artifactId&gt;selenium-java&lt;/artifactId&gt;
      &lt;version&gt;4.4.0&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  <ol>
  <li><p>Pulled docker images</p>
  <p>docker pull selenium/standalone-chrome:latest</p>
  </li>
  <li><p>Created two docker containers</p>
  <p>docker run -d -p 4441:4444 -v /dev/shm:/dev/shm selenium/standalone-chrome:latest
  a79389eb6fec65b3f7af82348c717e9e4b83d9ac1c318c4e952714c55606041d</p>
  <p>docker run -d -p 4440:4444 -v /dev/shm:/dev/shm selenium/standalone-chrome:latest
  e507c986e2848b8009b748b98edcb7d285871640b5a5e15016ade6a8ff0df3bf</p>
  </li>
  <li><p>Listing the containers that are running</p>
  </li>
  </ol>
  <p><a href="https://i.stack.imgur.com/ZZ8rL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZZ8rL.png" alt="enter image description here" /></a></p>
  <ol start="4">
  <li><p>Created a testNG test</p>
  <pre><code>     @Test
       public void test() throws MalformedURLException {
           String remote_url_chrome = &quot;http://localhost:4440/wd/hub&quot;;
           ChromeOptions chromeOptions = new ChromeOptions();
           driver = new RemoteWebDriver(new URL(remote_url_chrome), chromeOptions);
  
           System.out.println(&quot;DockerGrid1&quot;);
           driver.get(&quot;http://www.google.com&quot;);        
           wait(By.name(&quot;q&quot;));
           System.out.println(&quot;google: &quot; + driver.getTitle());
   }
  </code></pre>
  </li>
  <li><p>Run the testNG test and I get the following error:</p>
  <p>org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: Could not start a new session. Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: unknown error: Chrome failed to start: crashed.   (unknown error: DevToolsActivePort file doesn't exist)   (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) Build info: version: '4.4.0', revision: 'e5c75ed026a' System info: host: 'e507c986e284', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.16.3-microsoft-standard-WSL2', java.version: '11.0.16' Driver info: driver.version: unknown Build info: version: '4.4.0', revision: 'e5c75ed026a' System info: host: 'e507c986e284', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.16.3-microsoft-standard-WSL2', java.version: '11.0.16' Driver info: driver.version: unknown Build info: version: '4.4.0', revision: 'e5c75ed026a' System info: host: 'DESKTOP-RF8H5GJ', ip: '192.168.1.248', os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '18.0.1.1' Driver info: org.openqa.selenium.remote.RemoteWebDriver Command: [null, newSession {capabilities=[Capabilities {browserName: chrome, goog:chromeOptions: {args: [], extensions: []}}], desiredCapabilities=Capabilities {browserName: chrome, goog:chromeOptions: {args: [], extensions: []}}}] Capabilities {}    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:144)   at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:102)   at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:67)    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:156)     at org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:51)  at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:547)     at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)    at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:157)  at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:139)  at DockerGrid.BaseDockerGrid.startDockerGrid(BaseDockerGrid.java:46)    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)    at java.base/java.lang.reflect.Method.invoke(Method.java:577)   at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)     at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:62)    at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:385)  at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:321)   at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:176)     at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:122)  at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)   at org.testng.TestRunner.privateRun(TestRunner.java:794)    at org.testng.TestRunner.run(TestRunner.java:596)   at org.testng.SuiteRunner.runTest(SuiteRunner.java:377)     at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:371)     at org.testng.SuiteRunner.privateRun(SuiteRunner.java:332)  at org.testng.SuiteRunner.run(SuiteRunner.java:276)     at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)     at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)  at org.testng.TestNG.runSuitesSequentially(TestNG.java:1212)    at org.testng.TestNG.runSuitesLocally(TestNG.java:1134)     at org.testng.TestNG.runSuites(TestNG.java:1063)    at org.testng.TestNG.run(TestNG.java:1031)  at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)     at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)</p>
  </li>
  <li><p>Visited this url in my browser
  http://localhost:4440/grid/console</p>
  </li>
  </ol>
  <p><a href="https://i.stack.imgur.com/QXPC8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QXPC8.png" alt="enter image description here" /></a></p>
  <p>How can I run the test in docker container?</p>