{"record":{"id":"60b94a46b46eb70f","repo":"reflex-dev/reflex","slug":"backend-is-not-running","errorCode":null,"errorMessage":"Backend is not running.","messagePattern":"Backend is not running\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"reflex/testing.py","lineNumber":594,"sourceCode":"            await asyncio.sleep(step)\n        return False\n\n    def _poll_for_servers(self, timeout: TimeoutType = None) -> socket.socket:\n        \"\"\"Poll backend server for listening sockets.\n\n        Args:\n            timeout: how long to wait for listening socket.\n\n        Returns:\n            first active listening socket on the backend\n\n        Raises:\n            RuntimeError: when the backend hasn't started running\n            TimeoutError: when server or sockets are not ready\n        \"\"\"\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(","sourceCodeStart":576,"sourceCodeEnd":612,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/reflex/testing.py#L576-L612","documentation":"RuntimeError from AppHarness._poll_for_servers when self.backend is None: it tries to poll the uvicorn server's `servers` and `sockets`, so the backend must have been started first. It guards against polling a backend that was never launched.","triggerScenarios":"Calling _start_frontend or _poll_for_servers before _start_backend ran successfully, or after a failed start where backend was never assigned.","commonSituations":"Backend startup failed earlier (bad app import, port bind error) and the failure was swallowed; manual orchestration of harness internals in a custom fixture; calling start() with backend intentionally disabled.","solutions":["Ensure harness.start() completes and the backend actually launched; check earlier logs for the real backend failure","Assert `harness.backend is not None` before polling/using frontend utilities in custom fixtures","Use the standard `with AppHarness.create(...)` flow rather than manual start ordering"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if harness.backend is None:\n    harness.start()  # or fail fast with a clear message","typeGuard":"def backend_up(h) -> bool:\n    return getattr(h, \"backend\", None) is not None","tryCatchPattern":"try:\n    url = harness._poll_for_servers()\nexcept RuntimeError as e:\n    if \"Backend is not running\" in str(e):\n        harness.start()\n        url = harness._poll_for_servers()\n    else:\n        raise","preventionTips":["Always start the harness fully before using frontend/browser helpers","Check backend logs for the original startup failure"],"tags":["reflex","testing","app-harness","backend","lifecycle"],"backgroundTag":"service-not-initialized","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}