{"record":{"id":"010295ce8fe0c8ca","repo":"sgl-project/sglang","slug":"server-process-exited-with-code-return-code","errorCode":null,"errorMessage":"Server process exited with code {return_code}","messagePattern":"Server process exited with code (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"python/sglang/utils.py","lineNumber":542,"sourceCode":"    Terminate the process and automatically release the reserved port.\n    \"\"\"\n    from sglang.srt.utils import kill_process_tree\n\n    kill_process_tree(process.pid)\n\n    lock_socket = process_socket_map.pop(process, None)\n    if lock_socket is not None:\n        release_port(lock_socket)\n\n\ndef _raise_if_process_exited(process: Optional[Any]) -> None:\n    if process is None:\n        return\n\n    if hasattr(process, \"poll\"):\n        return_code = process.poll()\n        if return_code is not None:\n            raise RuntimeError(f\"Server process exited with code {return_code}\")\n        return\n\n    if hasattr(process, \"is_alive\") and not process.is_alive():\n        return_code = getattr(process, \"exitcode\", None)\n        if return_code is None:\n            raise RuntimeError(\"Server process exited\")\n        raise RuntimeError(f\"Server process exited with code {return_code}\")\n\n\ndef _is_wait_timeout(start_time: float, timeout: Optional[int]) -> bool:\n    if timeout is None:\n        return False\n    return time.perf_counter() - start_time > timeout\n\n\ndef wait_for_http_ready(\n    url: str,\n    timeout: Optional[int] = None,","sourceCodeStart":524,"sourceCodeEnd":560,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/utils.py#L524-L560","documentation":"wait_for_http_ready's _raise_if_process_exited polled the server process and found it already terminated with a known exit code, so readiness waiting aborts instead of hanging on a dead server.","triggerScenarios":"Server subprocess crashes during startup (bad args, OOM, CUDA error, import failure) while the test harness polls /health.","commonSituations":"Benchmarks/tests calling launch_server_cmd then wait_for_http_ready; server exits due to invalid model path or GPU error.","solutions":["Reproduce the server launch manually and read its stdout/stderr for the root cause","Fix the underlying startup failure (model path, GPU memory, flags)","Retain and print the process output in the test harness for diagnosis"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    wait_for_http_ready(server_process, url)\nexcept RuntimeError as e:\n    if 'exited with code' in str(e):\n        print(server_process.stdout.read())  # surface root cause","preventionTips":["Capture and print server stdout on failure","Validate server args (model path, GPUs) before launching"],"tags":["server","lifecycle","startup","subprocess"],"backgroundTag":"server-process-crashed-on-startup","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}