SessionNotCreatedException
SessionNotCreatedException: Causes and Fixes
Fix Selenium SessionNotCreatedException: browser/driver version mismatch, Selenium Manager and proxy TLS errors, user-data-dir in use, Grid capability mismatch.
| Java | org.openqa.selenium.SessionNotCreatedException |
|---|---|
| Python | selenium.common.exceptions.SessionNotCreatedException |
| JavaScript | SessionNotCreatedError |
| C# | System.InvalidOperationException |
What the error means
Your test never got a browser. The client asked the driver (chromedriver, geckodriver, msedgedriver, safaridriver, or a Grid) to start a new session, and the driver could not. No page was loaded and no test step ran.
Because it happens during setup, the cause is always environmental: the browser and driver do not match, the driver could not be obtained, the browser failed to launch with the options you gave it, or the Grid has nothing that satisfies your capabilities. The message text after session not created: tells you which.
What it looks like
// Java: version mismatchorg.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: session not created: This version of ChromeDriver only supports Chrome version 129Current browser version is 131.0.6778.86 with binary path C:\Program Files\Google\Chrome\Application\chrome.exe# Python: user data directory lockedselenium.common.exceptions.SessionNotCreatedException: Message: session not created: probably user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir// JavaScript (selenium-webdriver): browser crashed at startupSessionNotCreatedError: session not created: Chrome failed to start: exited normally. (session not created: DevToolsActivePort file doesn't exist)// C#System.InvalidOperationException : session not created: This version of ChromeDriver only supports Chrome version 129Current browser version is 131.0.6778.86 (SessionNotCreated).NET has no dedicated exception type for this W3C code: it falls through to the generic System.InvalidOperationException, with the W3C status name appended in parentheses. Catch on the message, not a Selenium type.
Selenium Manager failures appear slightly earlier, while locating the driver, and Java and Python report them as NoSuchDriverException:
# Python: Selenium Manager could not obtain a driverselenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain driver for chrome; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_locationCommon causes
- Browser and driver versions do not match. An old chromedriver on the
PATH, or pinned in a Docker image, while Chrome auto-updated. Chrome now ships every two weeks, so this drifts quickly. - Selenium Manager could not download the driver or browser. No internet access, a proxy that needs configuration, or, since Selenium 4.52, a TLS-intercepting corporate proxy whose certificate Selenium Manager no longer accepts.
- The user data directory is already in use. You pointed
--user-data-dirat your everyday Chrome profile while Chrome is open, or parallel tests share one profile directory. - The browser crashed on launch. Common in Linux containers: running as root without the right flags, a tiny
/dev/shm, or no display for a headed browser. - Grid has no node matching your capabilities. You requested a browser, version or platform that no node offers, or every matching slot is busy until the queue times out.
- Invalid capabilities or options. A misspelt vendor prefix or a value the driver rejects; that usually comes back as InvalidArgumentException but some drivers wrap it in session not created.
How to fix it
Browser and driver versions do not match
Let Selenium Manager handle it. Since Selenium 4.6 the bindings find or download the correct driver automatically, so you do not need WebDriverManager or a manually downloaded chromedriver. The usual reason it is not working is that an old driver on the PATH wins. Remove stale chromedriver binaries from the PATH (and from your repo, and from old CI images), then build the driver with no explicit path.
ChromeOptions options = new ChromeOptions();// Optional: ask for a specific browser; Selenium Manager can download Chrome for Testing// options.setBrowserVersion("stable");WebDriver driver = new ChromeDriver(options);options = webdriver.ChromeOptions()# options.browser_version = "stable"driver = webdriver.Chrome(options=options)const chrome = require('selenium-webdriver/chrome');const options = new chrome.Options();// options.setBrowserVersion('stable');const driver = await new Builder().forBrowser('chrome').setChromeOptions(options).build();var options = new ChromeOptions();// options.BrowserVersion = "stable";var driver = new ChromeDriver(options);Pinning browserVersion is a good way to stop auto-updates from changing your test browser mid-sprint: Selenium Manager downloads a matching Chrome for Testing build and driver into its cache (~/.cache/selenium). Also keep the Selenium client itself up to date; old clients ship old Selenium Manager binaries. See the Selenium Manager lesson.
Selenium Manager could not download the driver or browser
Find out what Selenium Manager is doing. It is a standalone binary bundled with each binding, and running it with --browser chrome --debug prints every resolution step. Your binding’s debug logging shows the same output.
Then work through the likely network causes:
- Proxy. Selenium Manager uses the proxy from your browser options when one is set, and can be given one explicitly (the
--proxyargument or theSE_PROXYenvironment variable). - TLS-intercepting corporate proxy (Selenium 4.52+). From 4.52, Selenium Manager validates TLS certificates on its downloads. Proxies that re-sign HTTPS traffic with a corporate root CA now cause certificate validation errors that older versions silently ignored. The proper fix is to make the corporate root CA trusted on the machine (your IT team’s standard CA bundle). 4.52 also updated its trust roots after the eMudhra CA distrust, so Python users seeing new certificate errors should also upgrade
certifi. There is an opt-in insecure mode that skips certificate validation for environments where neither is possible; checkselenium-manager --helpand the 4.52 release notes for the exact switch, and treat it as a last resort, since it removes the protection against tampered driver downloads. - No internet at all (air-gapped CI). Pre-install the browser and matching driver in your image and point the service at the driver explicitly, which skips the download entirely.
ChromeDriverService service = new ChromeDriverService.Builder() .usingDriverExecutable(new File("/opt/drivers/chromedriver")) .build();WebDriver driver = new ChromeDriver(service, new ChromeOptions());from selenium.webdriver.chrome.service import Service
service = Service(executable_path="/opt/drivers/chromedriver")driver = webdriver.Chrome(service=service, options=webdriver.ChromeOptions())const chrome = require('selenium-webdriver/chrome');const service = new chrome.ServiceBuilder('/opt/drivers/chromedriver');const driver = await new Builder().forBrowser('chrome').setChromeService(service).build();var service = ChromeDriverService.CreateDefaultService("/opt/drivers");var driver = new ChromeDriver(service, new ChromeOptions());If you take this route, you own version matching again. Rebuild the image whenever the browser changes.
The user data directory is already in use
Chrome locks a profile directory while it is running. Do not point tests at your personal profile, and never share one directory between parallel sessions. If you need a pre-seeded profile, copy it to a fresh temporary directory per session.
Path profile = Files.createTempDirectory("chrome-profile-");ChromeOptions options = new ChromeOptions();options.addArguments("--user-data-dir=" + profile.toAbsolutePath());import tempfile
profile = tempfile.mkdtemp(prefix="chrome-profile-")options = webdriver.ChromeOptions()options.add_argument(f"--user-data-dir={profile}")const fs = require('node:fs');const os = require('node:os');const path = require('node:path');const chrome = require('selenium-webdriver/chrome');
const profile = fs.mkdtempSync(path.join(os.tmpdir(), 'chrome-profile-'));const options = new chrome.Options().addArguments('--user-data-dir=' + profile);string profile = Path.Combine(Path.GetTempPath(), "chrome-profile-" + Guid.NewGuid());Directory.CreateDirectory(profile);var options = new ChromeOptions();options.AddArgument("--user-data-dir=" + profile);Usually the simplest fix is to remove --user-data-dir entirely; Chrome then creates a throwaway profile for each session. Leftover Chrome processes from crashed runs can also hold the lock, so make sure your teardown calls quit() in a finally block.
The browser crashed on launch
“DevToolsActivePort file doesn’t exist” and “Chrome failed to start” mean the browser process died before the driver could connect. In containers: run headless (--headless=new), give the container more shared memory (--shm-size=2g in Docker) or add --disable-dev-shm-usage, and avoid running as root. If you must run as root, Chrome needs --no-sandbox. Enable the driver log (see browser and driver logs) to see Chrome’s own stderr. The official selenium/standalone-* images already handle all of this.
Grid has no node matching your capabilities
Open the Grid UI (http://grid-host:4444/ui) and compare each node’s stereotype with what you request. Common mismatches: platformName “windows” against Linux nodes, a pinned browserVersion that no node has, or a vendor option the node does not support. When no slot matches, or every matching slot stays busy, the request sits in the new session queue until it times out, and the error reads like Could not start a new session. New session request timed out. Request only the capabilities you actually need, add nodes, or raise the queue timeout if the Grid is simply saturated. See the Selenium Grid lesson.
How to prevent it
- Delete manually managed drivers and let Selenium Manager match versions; pin
browserVersionif you need stability. - Update the Selenium client regularly. Old clients mean old Selenium Manager and old trust roots.
- Bake your corporate CA into CI images and developer machines rather than reaching for insecure modes.
- Use a fresh profile per session and always
quit()in teardown. - Use the official Selenium Docker images for Grid and container runs.
- Log the full capabilities you send so a Grid mismatch is obvious from the test output.
Related errors
- InvalidArgumentException: a capability or argument value the driver rejected.
- WebDriverException: the generic parent, including “chrome not reachable” and connection refused.
- InvalidSessionIdException: the session was created but died later.
Go deeper
- Selenium Manager and Driver Management How Selenium Manager finds or downloads the right browser driver (and browser), how to pin versions, configure caching, proxies and offline mode, and what to do when it fails in CI.
- Browser Options & Configuration Learn how to configure browser options in Selenium WebDriver, including headless mode, window size, and custom arguments.
- Selenium Grid Distribute tests across multiple machines and browsers using Selenium Grid for scalable test execution.
- Browser and Driver Logs Turn on the logs that explain failures: browser console output via BiDi, chromedriver and geckodriver logs, Selenium's own client logging, network failures, and how to collect them per test.