Skip to content
Latchkey

Selenium Grid "Could not start a new session" in CI

A RemoteWebDriver request reaches the Grid hub, but the hub cannot complete a session: either the remote address is wrong, or a node accepted the slot and the browser failed to start there. The error names both possibilities.

What this error means

The test fails with "org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure." pointing at the Grid endpoint.

selenium
SessionNotCreatedException: Could not start a new session.
Possible causes are invalid address of the remote server or browser start-up failure.
Host info: host: 'grid-hub', ip: '10.0.0.5'
Build info: version: '4.21.0'

Common causes

The remote URL is wrong or unreachable

The RemoteWebDriver points at a hub address the runner cannot reach, or at /wd/hub on a Grid version that moved the endpoint.

A node accepted the slot but the browser crashed

The node started the browser without container-safe flags, so it crashed at startup and the session could not be created.

How to fix it

Point at the right hub URL and pass safe flags

  1. Use the correct Grid endpoint for your version (Selenium 4 uses the hub root, not always /wd/hub).
  2. Pass --no-sandbox and --disable-dev-shm-usage via browser options so the node browser starts.
  3. Re-run so the node creates the session.
python
from selenium.webdriver.chrome.options import Options
opts = Options(); opts.add_argument("--no-sandbox"); opts.add_argument("--disable-dev-shm-usage")
driver = webdriver.Remote(command_executor="http://grid-hub:4444", options=opts)

Wait for the Grid to be ready

Poll the Grid status endpoint until it reports ready before sending sessions so the hub and nodes are up.

.github/workflows/ci.yml
- run: |
    for i in $(seq 1 30); do
      curl -sf http://grid-hub:4444/status | grep -q '"ready": *true' && break || sleep 2
    done

How to prevent it

  • Use the correct Grid endpoint for the Selenium version.
  • Pass container-safe browser flags so node browsers start.
  • Poll /status for ready before dispatching sessions.

Frequently asked questions

What causes ""Could not start a new session""?
The RemoteWebDriver points at a hub address the runner cannot reach, or at /wd/hub on a Grid version that moved the endpoint.
How do I fix "Could not start a new session"?
Point at the right hub URL and pass safe flags

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card