{"record":{"id":"6efb9a1ef46eaf9f","repo":"SeleniumHQ/selenium","slug":"timed-out-waiting-for-selenium-server-at-self-sta","errorCode":null,"errorMessage":"Timed out waiting for Selenium server at {self.status_url}","messagePattern":"Timed out waiting for Selenium server at (.+?)","errorType":"exception","errorClass":"TimeoutError","httpStatus":null,"severity":"error","filePath":"py/selenium/webdriver/remote/server.py","lineNumber":216,"sourceCode":"            \"--log-level\",\n            self.log_level,\n            *self.args,\n        ]\n        if self.host is not None:\n            command.extend([\"--host\", self.host])\n\n        host = self.host if self.host is not None else \"localhost\"\n\n        try:\n            with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:\n                sock.connect((host, self.port))\n            raise ConnectionError(f\"Selenium server is already running, or something else is using port {self.port}\")\n        except ConnectionRefusedError:\n            print(\"Starting Selenium server...\")\n            self.process = subprocess.Popen(command, env=self.env)\n            print(f\"Selenium server running as process: {self.process.pid}\")\n            if not self._wait_for_server(timeout=self.startup_timeout):\n                raise TimeoutError(f\"Timed out waiting for Selenium server at {self.status_url}\")\n            print(\"Selenium server is ready\")\n        return self.process\n\n    def stop(self):\n        \"\"\"Stop the server.\"\"\"\n        if self.process is None:\n            raise RuntimeError(\"Selenium server isn't running\")\n        else:\n            if self.process.poll() is None:\n                self.process.terminate()\n                self.process.wait()\n            self.process = None\n            print(\"Selenium server has been terminated\")\n","sourceCodeStart":198,"sourceCodeEnd":230,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/py/selenium/webdriver/remote/server.py#L198-L230","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Increase startup_timeout, e.g. Server(startup_timeout=120).","Inspect the spawned java process stderr/stdout to see why it never came up.","Confirm host/port of status_url matches the --host/--port the server actually bound to.","Pre-download the server JAR (set self.path) so startup isn't spent downloading."],"exampleFix":"# before\nserver = Server(startup_timeout=10)\nserver.start()\n\n# after\nserver = Server(startup_timeout=120)\nserver.start()","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    server.start()\nexcept TimeoutError:\n    # read server.process stderr, raise startup_timeout, or retry after diagnosis","preventionTips":["Budget generous startup timeouts on CI and cold hosts.","Log server.process stdout/stderr to diagnose boot failures quickly."],"tags":["network","timeout","environment","server-runner"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}