sgl-project/sglang · critical · RuntimeError

Server process exited with code

Error message

Server process exited with code {return_code}

What it means

Launched server/helper process terminated with a non-zero exit code (value in the message). Raised by the local-server helpers so callers see the child failure instead of hanging on health checks; check the captured stdout/stderr for the root cause.

Solutions

  1. Reproduce the server launch manually and read its stdout/stderr for the root cause
  2. Fix the underlying startup failure (model path, GPU memory, flags)
  3. Retain and print the process output in the test harness for diagnosis
Defensive patterns

Strategy: try-catch

Try / catch

try:
    wait_for_http_ready(server_process, url)
except RuntimeError as e:
    if 'exited with code' in str(e):
        print(server_process.stdout.read())  # surface root cause

Prevention

When it happens

Trigger: Server subprocess crashes during startup (bad args, OOM, CUDA error, import failure) while the test harness polls /health.

Common situations: Benchmarks/tests calling launch_server_cmd then wait_for_http_ready; server exits due to invalid model path or GPU error.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/010295ce8fe0c8ca. Report an issue: GitHub.

Appendix: source

Thrown at python/sglang/utils.py:542

    Terminate the process and automatically release the reserved port.
    """
    from sglang.srt.utils import kill_process_tree

    kill_process_tree(process.pid)

    lock_socket = process_socket_map.pop(process, None)
    if lock_socket is not None:
        release_port(lock_socket)


def _raise_if_process_exited(process: Optional[Any]) -> None:
    if process is None:
        return

    if hasattr(process, "poll"):
        return_code = process.poll()
        if return_code is not None:
            raise RuntimeError(f"Server process exited with code {return_code}")
        return

    if hasattr(process, "is_alive") and not process.is_alive():
        return_code = getattr(process, "exitcode", None)
        if return_code is None:
            raise RuntimeError("Server process exited")
        raise RuntimeError(f"Server process exited with code {return_code}")


def _is_wait_timeout(start_time: float, timeout: Optional[int]) -> bool:
    if timeout is None:
        return False
    return time.perf_counter() - start_time > timeout


def wait_for_http_ready(
    url: str,
    timeout: Optional[int] = None,

View on GitHub (pinned to 0132848349)