SeleniumHQ/selenium · error · TimeoutError

Timed out waiting for Selenium server at {self.status_url}

Error message

Timed out waiting for Selenium server at {self.status_url}

What it means

Raised when `_wait_for_server` cannot GET the status_url within `startup_timeout` seconds. The runner polls `urllib.request.urlopen(self.status_url)` in a loop; if the server never answers (URLError each try) before the deadline, it gives up. It is a TimeoutError.

Source

Thrown at py/selenium/webdriver/remote/server.py:216

            "--log-level",
            self.log_level,
            *self.args,
        ]
        if self.host is not None:
            command.extend(["--host", self.host])

        host = self.host if self.host is not None else "localhost"

        try:
            with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
                sock.connect((host, self.port))
            raise ConnectionError(f"Selenium server is already running, or something else is using port {self.port}")
        except ConnectionRefusedError:
            print("Starting Selenium server...")
            self.process = subprocess.Popen(command, env=self.env)
            print(f"Selenium server running as process: {self.process.pid}")
            if not self._wait_for_server(timeout=self.startup_timeout):
                raise TimeoutError(f"Timed out waiting for Selenium server at {self.status_url}")
            print("Selenium server is ready")
        return self.process

    def stop(self):
        """Stop the server."""
        if self.process is None:
            raise RuntimeError("Selenium server isn't running")
        else:
            if self.process.poll() is None:
                self.process.terminate()
                self.process.wait()
            self.process = None
            print("Selenium server has been terminated")

View on GitHub (pinned to aa36b38e69)

Solutions

  1. Increase startup_timeout, e.g. Server(startup_timeout=120).
  2. Inspect the spawned java process stderr/stdout to see why it never came up.
  3. Confirm host/port of status_url matches the --host/--port the server actually bound to.
  4. Pre-download the server JAR (set self.path) so startup isn't spent downloading.

Example fix

# before
server = Server(startup_timeout=10)
server.start()

# after
server = Server(startup_timeout=120)
server.start()
Defensive patterns

Strategy: retry

Try / catch

try:
    server.start()
except TimeoutError:
    # read server.process stderr, raise startup_timeout, or retry after diagnosis

Prevention

When it happens

Trigger: Calling start() with a too-short startup_timeout, a slow/cold JVM first start, the server binding to a different host/port than status_url, firewall/loopback restrictions, or the java process crashing on boot (bad JAR, OOM, JVM flags).

Common situations: Under-provisioned CI where JVM startup exceeds the default timeout; server JAR download still in progress via Selenium Manager; host misconfiguration where status_url points at 'localhost' but server bound to 127.0.0.1 only on some OSes; SELinux blocking the local socket.

Understand the failure class

Related errors


AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14). Data as JSON: /api/errors/6efb9a1ef46eaf9f. Report an issue: GitHub.