{"record":{"id":"1200d03304253de3","repo":"sgl-project/sglang","slug":"failed-to-get-server-info-error-data-error-m","errorCode":null,"errorMessage":"Failed to get server info. {error_data['error']['message']}","messagePattern":"Failed to get server info\\. (.+?)","errorType":"error_code","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/sglang/lang/backend/runtime_endpoint.py","lineNumber":554,"sourceCode":"        )\n        return json.dumps(response.json())\n\n    def encode(\n        self,\n        prompt: Union[str, List[str], List[Dict], List[List[Dict]]],\n    ):\n        json_data = {\"text\": prompt}\n        response = requests.post(self.url + \"/encode\", json=json_data)\n        return json.dumps(response.json())\n\n    async def get_server_info(self):\n        async with aiohttp.ClientSession() as session:\n            async with session.get(f\"{self.url}/server_info\") as response:\n                if response.status == 200:\n                    return await response.json()\n                else:\n                    error_data = await response.json()\n                    raise RuntimeError(\n                        f\"Failed to get server info. {error_data['error']['message']}\"\n                    )\n\n    def __del__(self):\n        self.shutdown()\n","sourceCodeStart":536,"sourceCodeEnd":560,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/lang/backend/runtime_endpoint.py#L536-L560","documentation":"Raised by RuntimeEndpoint.get_server_info when the SGLang server's /server_info endpoint returns a non-200 status. The response body is expected to contain {'error': {'message': ...}} and that message is surfaced in the exception. It means the HTTP request reached something, but the server rejected it or is unhealthy.","triggerScenarios":"Calling endpoint.get_server_info() (directly or via lang frontends that fetch server info) when the server at self.url is down/misrouted, the URL points to a non-SGLang service, the server is still starting up, or a proxy/gateway returns an error JSON body. Also triggers if the error body lacks the 'error'/'message' keys, producing a KeyError instead.","commonSituations":"Wrong --port or host in the RuntimeEndpoint URL; server not yet ready when the client connects; hitting an ingress that returns its own error JSON; version mismatch where /server_info was renamed or requires auth.","solutions":["Verify the server is up: curl http://<host>:<port>/health and curl http://<host>:<port>/server_info","Fix the URL passed to RuntimeEndpoint (correct host/port)","Wait for server readiness (health check loop) before calling get_server_info","If behind a proxy/auth, ensure it forwards /server_info unmodified or bypass it"],"exampleFix":"// before\nendpoint = RuntimeEndpoint(\"http://localhost:30000\")\ninfo = endpoint.get_server_info()\n// after\nendpoint = RuntimeEndpoint(\"http://localhost:30000\")\n# wait until healthy\nimport requests, time\nfor _ in range(60):\n    try:\n        if requests.get(\"http://localhost:30000/health\", timeout=2).status_code == 200:\n            break\n    except Exception:\n        pass\n    time.sleep(1)\ninfo = endpoint.get_server_info()","handlingStrategy":"retry","validationCode":"import requests\ndef server_ready(url, tries=30, delay=1):\n    for _ in range(tries):\n        try:\n            if requests.get(f\"{url}/server_info\", timeout=2).status_code == 200:\n                return True\n        except Exception:\n            pass\n        time.sleep(delay)\n    return False\nassert server_ready(\"http://localhost:30000\")","typeGuard":null,"tryCatchPattern":"try:\n    info = endpoint.get_server_info()\nexcept (RuntimeError, KeyError) as e:\n    # KeyError if error body lacks 'error'/'message'\n    logger.error(\"server_info failed: %s\", e)\n    raise","preventionTips":["Run a /health or /server_info readiness probe before issuing requests","Validate the RuntimeEndpoint URL (host/port) at construction time","Don't put auth proxies in front of /server_info unless they pass through SGLang's JSON"],"tags":["http","server-info","startup","network"],"backgroundTag":"http-endpoint-unhealthy","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}