Skip to main content
SeleniumDecoded

WebDriverException

WebDriverException: Causes and Fixes

Fix Selenium WebDriverException (WebDriverError in JS): chrome not reachable, connection refused, unknown error, net::ERR messages and client HTTP timeouts.

Common W3C: unknown error Verified against Selenium 4.52.0
Exception name by language
Java org.openqa.selenium.WebDriverException
Python selenium.common.exceptions.WebDriverException
JavaScript WebDriverError
C# OpenQA.Selenium.WebDriverException

What the error means

WebDriverException is the base class for every Selenium error. All the specific exceptions on this site (NoSuchElementException, TimeoutException and the rest) extend it. When you see the plain WebDriverException, it means no more specific type fits: usually the W3C unknown error code, a driver crash, or a failure in the HTTP connection between your client and the driver.

So the class name tells you almost nothing. The message tells you everything. Group your diagnosis by the first line of the message:

Message starts withWhere the problem is
unknown error: net::ERR_...The browser could not load the URL
unknown error: cannot find Chrome binary / no chrome binaryBrowser not installed where the driver looks
chrome not reachable / disconnected: not connected to DevToolsThe browser process died or hung
Connection refused / Could not start a new session / ECONNREFUSEDThe driver or Grid is not listening
Read timeout / SocketTimeoutExceptionA command took longer than the client’s HTTP timeout

What it looks like

// Java: navigation failure
org.openqa.selenium.WebDriverException: unknown error: net::ERR_CONNECTION_REFUSED
(Session info: chrome=131.0.6778.86)
# Python: browser died mid-test
selenium.common.exceptions.WebDriverException: Message: disconnected: not connected to DevTools
(failed to check if window was closed: disconnected: not connected to DevTools)
(Session info: chrome=131.0.6778.86)
// JavaScript (selenium-webdriver): driver not running
Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:4444
// C#: HTTP timeout to the driver
OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://localhost:52713/session/8d1c.../url timed out after 60 seconds.
----> System.Threading.Tasks.TaskCanceledException : The request was canceled due to the configured HttpClient.Timeout of 60 seconds elapsing.

In Java, an HTTP read timeout shows up with a java.net.http.HttpTimeoutException or similar in the cause chain; in Python, network-level failures between client and driver often surface as urllib3 exceptions (MaxRetryError, ReadTimeoutError) rather than WebDriverException.

Common causes

  1. The application under test is not reachable. net::ERR_CONNECTION_REFUSED, ERR_NAME_NOT_RESOLVED, or ERR_CERT_AUTHORITY_INVALID because the app is down, the URL is wrong, or localhost means something different inside a container.
  2. The browser crashed or hung. Memory pressure, a small /dev/shm, a renderer crash, or a modal native dialog freezing the browser.
  3. The driver or Grid is not running or not reachable. Wrong remote URL, wrong port, the Grid is still starting, or a firewall in between.
  4. A command exceeded the client HTTP timeout. A very slow page load or script outlasted the client’s read timeout.
  5. The browser binary cannot be found. A custom install location or a container without the browser.

How to fix it

The application under test is not reachable

Open the same URL from the machine (or container) where the browser runs, for example with curl. In Docker, localhost inside the browser container is the container itself, not your host: use the service name on a shared network, or host.docker.internal where supported. For self-signed certificates in test environments, accept insecure certificates explicitly.

Accept self-signed certificates in test environments
Selenium 4 Medium
ChromeOptions options = new ChromeOptions();
options.setAcceptInsecureCerts(true);
WebDriver driver = new ChromeDriver(options);
options = webdriver.ChromeOptions()
options.accept_insecure_certs = True
driver = webdriver.Chrome(options=options)
const chrome = require('selenium-webdriver/chrome');
const options = new chrome.Options().setAcceptInsecureCerts(true);
const driver = await new Builder().forBrowser('chrome').setChromeOptions(options).build();
var options = new ChromeOptions { AcceptInsecureCertificates = true };
var driver = new ChromeDriver(options);

The browser crashed or hung

Messages like chrome not reachable, disconnected: not connected to DevTools and session deleted because of page crash mean the browser went away. In containers, raise shared memory (--shm-size=2g) or add --disable-dev-shm-usage, run fewer browsers per host, and run headless. Turn on driver logging to see what Chrome printed before it died; see browser and driver logs. After a crash the session is usually unusable, and the next command fails with InvalidSessionIdException.

The driver or Grid is not running or not reachable

Check the remote URL and that the Grid is ready before tests start. Grid exposes a status endpoint (/status) whose ready field you can poll from your CI script. Wait for it rather than starting tests the moment the container starts.

Connect to a Grid with an explicit URL
Selenium 4 Stable
URL gridUrl = URI.create(System.getenv().getOrDefault("GRID_URL", "http://localhost:4444")).toURL();
WebDriver driver = new RemoteWebDriver(gridUrl, new ChromeOptions());
import os
grid_url = os.environ.get("GRID_URL", "http://localhost:4444")
driver = webdriver.Remote(command_executor=grid_url, options=webdriver.ChromeOptions())
const chrome = require('selenium-webdriver/chrome');
const gridUrl = process.env.GRID_URL || 'http://localhost:4444';
const driver = await new Builder()
.usingServer(gridUrl)
.forBrowser('chrome')
.setChromeOptions(new chrome.Options())
.build();
var gridUrl = new Uri(Environment.GetEnvironmentVariable("GRID_URL") ?? "http://localhost:4444");
var driver = new RemoteWebDriver(gridUrl, new ChromeOptions());

Note that Grid 4 does not need the old /wd/hub suffix, although it still accepts it.

A command exceeded the client HTTP timeout

The client gives up on a single HTTP request after its own timeout (commonly 60 seconds in .NET, configurable in every binding). If a page load timeout or script timeout is set higher than that, the client times out first with a confusing low-level error. Keep page load and script timeouts below the client HTTP timeout so you get a clear TimeoutException instead. In .NET you can pass a longer command timeout to the driver constructor; Java’s ClientConfig and Python’s ClientConfig offer the same control for remote sessions.

The browser binary cannot be found

Install the browser, or let Selenium Manager download one by setting a browser version in options (see SessionNotCreatedException). For a non-standard install location, set the binary path in options (setBinary in Java, binary_location in Python, setChromeBinaryPath in JavaScript, BinaryLocation in C#).

How to prevent it

  • Health-check the application and the Grid before the suite starts, and fail fast with a clear message if either is down.
  • Run browsers in properly sized containers using the official Selenium images.
  • Keep browser-side timeouts lower than the client HTTP timeout.
  • Log the full message and cause chain on failure, not just the exception class; the class is always the same.
  • Keep the Selenium client current; many “unknown error” crashes are fixed driver and client bugs.

Go deeper