{"record":{"id":"34a8b57455d9bcf7","repo":"reflex-dev/reflex","slug":"backend-is-not-listening","errorCode":null,"errorMessage":"Backend is not listening.","messagePattern":"Backend is not listening\\.","errorType":"exception","errorClass":"TimeoutError","httpStatus":null,"severity":"error","filePath":"reflex/testing.py","lineNumber":609,"sourceCode":"        \"\"\"\n        if self.backend is None:\n            msg = \"Backend is not running.\"\n            raise RuntimeError(msg)\n        backend = self.backend\n        # check for servers to be initialized\n        if not self._poll_for(\n            target=lambda: getattr(backend, \"servers\", False),\n            timeout=timeout,\n        ):\n            msg = \"Backend servers are not initialized.\"\n            raise TimeoutError(msg)\n        # check for sockets to be listening\n        if not self._poll_for(\n            target=lambda: getattr(backend.servers[0], \"sockets\", False),\n            timeout=timeout,\n        ):\n            msg = \"Backend is not listening.\"\n            raise TimeoutError(msg)\n        return backend.servers[0].sockets[0]\n\n    def frontend(\n        self,\n        driver_clz: type[WebDriver] | None = None,\n        driver_kwargs: dict[str, Any] | None = None,\n        driver_options: ArgOptions | None = None,\n        driver_option_args: list[str] | None = None,\n        driver_option_capabilities: dict[str, Any] | None = None,\n    ) -> WebDriver:\n        \"\"\"Get a selenium webdriver instance pointed at the app.\n\n        Args:\n            driver_clz: webdriver.Chrome (default), webdriver.Firefox, webdriver.Safari,\n                webdriver.Edge, etc\n            driver_kwargs: additional keyword arguments to pass to the webdriver constructor\n            driver_options: selenium ArgOptions instance to pass to the webdriver constructor\n            driver_option_args: additional arguments for the webdriver options","sourceCodeStart":591,"sourceCodeEnd":627,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/reflex/testing.py#L591-L627","documentation":"TimeoutError raised by AppHarness._poll_for_servers when the first uvicorn server exists but its `sockets` list is still empty after the polling timeout — the server object was created but never bound/listened on a socket.","triggerScenarios":"uvicorn configured on port 0 or a busy port where binding is delayed/failing, or the server's serve() coroutine hasn't run far enough to open sockets within the timeout.","commonSituations":"Port conflicts from parallel tests or stale processes; firewall/permission issues binding sockets; heavily loaded CI host delaying socket creation.","solutions":["Ensure no stale process holds the target port; pass port=0 to let the OS pick a free port","Free stale backend processes between test sessions","Increase resources/reduce parallelism on the CI runner so binding completes in time"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"import socket\nwith socket.socket() as s:\n    s.bind((\"127.0.0.1\", 0))  # verify binding works; prefer port=0 for the backend","typeGuard":null,"tryCatchPattern":"try:\n    harness.start()\nexcept TimeoutError as e:\n    if \"listening\" in str(e):\n        # likely port conflict; clean up and retry\n        harness.start()\n    else:\n        raise","preventionTips":["Launch backends on port 0 to avoid conflicts","Terminate stale reflex/node processes between test sessions"],"tags":["reflex","testing","app-harness","backend","socket","timeout"],"backgroundTag":"server-not-listening","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}