BerriAI/litellm · error · ProcessLaunchError

Ephemeral proxy exited early

Error message

Ephemeral proxy exited early (code {process.returncode}). Last log lines:
{_tail(log_path)}

What it means

The spawned ephemeral proxy process terminated before its liveliness endpoint answered; the launcher reports the exit code plus the last 40 log lines to expose startup failures (bad config, port conflict).

Solutions

  1. Read the logged tail lines to find why the proxy exited.
  2. Fix the proxy config/port conflict and retry.

Example fix

Check the ephemeral proxy log file shown in the error message.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at litellm/proxy/client/cli/commands/autoroute/process.py:101 when the library encounters an invalid state.

Common situations: The ephemeral proxy process crashed during startup.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/a975f4dbf6ecfa63. Report an issue: GitHub.

Appendix: source

Thrown at litellm/proxy/client/cli/commands/autoroute/process.py:101

            ],
            stdout=log_file,
            stderr=subprocess.STDOUT,
        )


def _tail(log_path: Path, lines: int = 40) -> str:
    if not log_path.exists():
        return "(no log output captured)"
    return "\n".join(log_path.read_text(errors="replace").splitlines()[-lines:])


def poll_liveliness(base_url: str, log_path: Path, process: "subprocess.Popen[bytes]", timeout: float = 30.0) -> None:
    """Poll /health/liveliness until it responds, the process dies, or timeout elapses."""
    deadline: Final = time.monotonic() + timeout
    url: Final = base_url.rstrip("/") + "/health/liveliness"
    while time.monotonic() < deadline:
        if process.poll() is not None:
            raise ProcessLaunchError(
                f"Ephemeral proxy exited early (code {process.returncode}). Last log lines:\n{_tail(log_path)}"
            )
        with contextlib.suppress(requests.RequestException):
            if requests.get(url, timeout=2).status_code == 200:
                return
        time.sleep(0.5)
    raise ProcessLaunchError(
        f"Ephemeral proxy never became healthy within {timeout}s. Last log lines:\n{_tail(log_path)}"
    )


def write_pid_record(record: PidRecord, path: Path | None = None) -> None:
    resolved_path: Final = path if path is not None else PID_RECORD_PATH
    resolved_path.parent.mkdir(parents=True, exist_ok=True)
    with open(resolved_path, "w") as f:
        json.dump(
            {"pid": record.pid, "port": record.port, "config_path": record.config_path, "log_path": record.log_path},
            f,

View on GitHub (pinned to 77b7c6c40c)