{"record":{"id":"1881c473ae7e7506","repo":"sgl-project/sglang","slug":"could-not-connect-to-remote-scheduler-at-self-ser","errorCode":null,"errorMessage":"Could not connect to remote scheduler at {self.server_args.scheduler_endpoint} with `local mode` as False. Please ensure the server is running.","messagePattern":"Could not connect to remote scheduler at (.+?) with `local mode` as False\\. Please ensure the server is running\\.","errorType":"exception","errorClass":"ConnectionError","httpStatus":null,"severity":"critical","filePath":"python/sglang/multimodal_gen/runtime/entrypoints/diffusion_generator.py","lineNumber":200,"sourceCode":"    ) -> list[mp.Process]:\n        \"\"\"Check if a local server is running; if not, start it and return the process handles.\"\"\"\n        # First, we need a client to test the server. Initialize it temporarily.\n        sync_scheduler_client.initialize(self.server_args)\n\n        processes = launch_server(self.server_args, launch_http_server=False)\n\n        return processes\n\n    def _run_client_warmup_if_needed(self) -> None:\n        if not should_run_explicit_client_warmup(self.server_args):\n            return\n\n        run_sync_client_warmup(self.server_args, sync_scheduler_client.forward)\n\n    def _check_remote_scheduler(self):\n        \"\"\"Check if the remote scheduler is accessible.\"\"\"\n        if not sync_scheduler_client.ping():\n            raise ConnectionError(\n                f\"Could not connect to remote scheduler at \"\n                f\"{self.server_args.scheduler_endpoint} with `local mode` as False. \"\n                \"Please ensure the server is running.\"\n            )\n        logger.info(\n            f\"Successfully connected to remote scheduler at \"\n            f\"{self.server_args.scheduler_endpoint}.\"\n        )\n\n    @staticmethod\n    def _resolve_image_paths_per_prompt(\n        prompts: list[str], image_paths: str | list[str] | None\n    ) -> list[str | list[str] | None]:\n        if len(prompts) <= 1:\n            return [image_paths]\n\n        if not isinstance(image_paths, list) or len(image_paths) <= 1:\n            return [image_paths for _ in prompts]","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/entrypoints/diffusion_generator.py#L182-L218","documentation":"Raised by DiffGenerator._check_remote_scheduler when the synchronous scheduler client's ping() fails while server_args has local mode disabled. The generator expected a remote scheduler at server_args.scheduler_endpoint but could not reach it, so construction via from_server_args aborts with ConnectionError.","triggerScenarios":"Instantiating DiffGenerator.from_server_args(server_args) with local_mode=False when no scheduler is listening at scheduler_endpoint — server not started, wrong host/port, firewall blocking, or scheduler crashed after startup.","commonSituations":"Forgetting to launch the scheduler before the client, wrong port in server_args, scheduler bound to localhost only while client runs in another container, k8s service not ready yet.","solutions":["Start the scheduler first (e.g. `sglang serve ...`) and confirm it logs readiness at the same endpoint","Verify scheduler_endpoint host/port in server_args matches where the scheduler is listening; test with a raw TCP/curl connect","If cross-host, make sure the scheduler binds 0.0.0.0 and firewalls allow the port; in k8s wait for the service/readiness probe","If you intended in-process generation, set local mode instead of connecting remotely"],"exampleFix":"# before\ngenerator = DiffGenerator.from_server_args(server_args)  # local_mode=False, scheduler not up\n\n# after\n# terminal 1: sglang serve --model-path ... --port 30000\ngenerator = DiffGenerator.from_server_args(server_args)  # scheduler reachable","handlingStrategy":"retry","validationCode":"import socket\nfrom urllib.parse import urlparse\nhost, port = parse_endpoint(server_args.scheduler_endpoint)\nwith socket.create_connection((host, port), timeout=5):\n    pass  # scheduler reachable","typeGuard":null,"tryCatchPattern":"for attempt in range(5):\n    try:\n        gen = DiffGenerator.from_server_args(server_args)\n        break\n    except ConnectionError:\n        time.sleep(2 * (attempt + 1))\nelse:\n    raise RuntimeError(\"scheduler never became reachable\")","preventionTips":["Start the scheduler and wait for its readiness log before constructing the client","Use an absolute host/port in scheduler_endpoint and verify with a TCP probe","In k8s, gate client startup on the scheduler service's readiness probe"],"tags":["connection","scheduler","remote-mode","startup"],"backgroundTag":"connection-refused","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}