{"record":{"id":"4163a62f9ed801a2","repo":"huggingface/transformers","slug":"no-server-currently-running-on-url-to-run-a-loc","errorCode":null,"errorMessage":"No server currently running on {url}. To run a local server, please run `transformers serve` in a separate shell. Find more information here: https://huggingface.co/docs/transformers/serving","messagePattern":"No server currently running on (.+?)\\. To run a local server, please run `transformers serve` in a separate shell\\. Find more information here: https://huggingface\\.co/docs/transformers/serving","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/transformers/cli/chat.py","lineNumber":394,"sourceCode":"\n        # Check requirements\n        if not is_rich_available():\n            raise ImportError(\"You need to install rich to use the chat interface. (`pip install rich`)\")\n\n        # Run chat session\n        asyncio.run(self._inner_run())\n\n    @staticmethod\n    def check_health(url):\n        health_url = urljoin(get_service_root_url(url) + \"/\", \"health\")\n        try:\n            output = httpx.get(health_url)\n            if output.status_code != 200:\n                raise ValueError(\n                    f\"The server running on {url} returned status code {output.status_code} on health check (/health).\"\n                )\n        except httpx.ConnectError:\n            raise ValueError(\n                f\"No server currently running on {url}. To run a local server, please run `transformers serve` in a\"\n                f\"separate shell. Find more information here: https://huggingface.co/docs/transformers/serving\"\n            )\n\n        return True\n\n    def handle_non_exit_user_commands(\n        self,\n        user_input: str,\n        interface: RichInterface,\n        examples: dict[str, dict[str, str]],\n        config: GenerationConfig,\n        chat: list[dict],\n    ) -> tuple[list[dict], GenerationConfig]:\n        \"\"\"\n        Handles all user commands except for `!exit`. May update the chat history (e.g. reset it) or the\n        generation config (e.g. set a new flag).\n        \"\"\"","sourceCodeStart":376,"sourceCodeEnd":412,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/cli/chat.py#L376-L412","documentation":"check_health catches httpx.ConnectError while probing {service_root}/health. A ConnectError means nothing accepted the TCP connection at that address — no server is running there. The error advises starting `transformers serve` in another shell.","triggerScenarios":"Running `transformers chat` without having started `transformers serve`; wrong host/port; server bound to a different interface (localhost vs 0.0.0.0/LAN); firewall or Docker networking blocking the port; server already exited.","commonSituations":"Forgot to start the server; server started on a non-default port; inside a container trying to reach the host's server via localhost; typo in the URL; server crashed right after launch.","solutions":["Start the server: transformers serve --model_id <id> (default localhost:8000)","Pass the matching URL to chat: transformers chat --url http://localhost:<same-port>","If server and client are in different containers/hosts, bind the server to an reachable interface and use that address","Verify the port is listening: curl http://localhost:8000/health or ss -ltnp"],"exampleFix":"# before (server not started)\ntransformers chat  # ValueError: No server currently running\n\n# after\n# shell 1\ntransformers serve --model_id gpt2\n# shell 2\ntransformers chat","handlingStrategy":"retry","validationCode":"import socket\n\nhost, port = \"localhost\", 8000\nwith socket.create_connection((host, port), timeout=1):\n    pass  # server reachable","typeGuard":null,"tryCatchPattern":"import time, socket\nfor _ in range(60):\n    try:\n        with socket.create_connection((\"localhost\", 8000), timeout=1):\n            break\n    except OSError:\n        time.sleep(1)\nelse:\n    raise RuntimeError(\"transformers serve did not come up\")","preventionTips":["Always start `transformers serve` before `transformers chat` (separate shells)","Pin the port explicitly on both sides: serve --port 8000, chat --url http://localhost:8000","In containers, bind serve to 0.0.0.0 and address it by service name/host IP, not localhost"],"tags":["cli","chat","connection-refused","network","serving"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}