{"record":{"id":"a975f4dbf6ecfa63","repo":"BerriAI/litellm","slug":"ephemeral-proxy-exited-early-code-process-return","errorCode":null,"errorMessage":"Ephemeral proxy exited early (code {process.returncode}). Last log lines:\n{_tail(log_path)}","messagePattern":"Ephemeral proxy exited early \\(code (.+?)\\)\\. Last log lines:\n(.+?)","errorType":"exception","errorClass":"ProcessLaunchError","httpStatus":null,"severity":"error","filePath":"litellm/proxy/client/cli/commands/autoroute/process.py","lineNumber":101,"sourceCode":"            ],\n            stdout=log_file,\n            stderr=subprocess.STDOUT,\n        )\n\n\ndef _tail(log_path: Path, lines: int = 40) -> str:\n    if not log_path.exists():\n        return \"(no log output captured)\"\n    return \"\\n\".join(log_path.read_text(errors=\"replace\").splitlines()[-lines:])\n\n\ndef poll_liveliness(base_url: str, log_path: Path, process: \"subprocess.Popen[bytes]\", timeout: float = 30.0) -> None:\n    \"\"\"Poll /health/liveliness until it responds, the process dies, or timeout elapses.\"\"\"\n    deadline: Final = time.monotonic() + timeout\n    url: Final = base_url.rstrip(\"/\") + \"/health/liveliness\"\n    while time.monotonic() < deadline:\n        if process.poll() is not None:\n            raise ProcessLaunchError(\n                f\"Ephemeral proxy exited early (code {process.returncode}). Last log lines:\\n{_tail(log_path)}\"\n            )\n        with contextlib.suppress(requests.RequestException):\n            if requests.get(url, timeout=2).status_code == 200:\n                return\n        time.sleep(0.5)\n    raise ProcessLaunchError(\n        f\"Ephemeral proxy never became healthy within {timeout}s. Last log lines:\\n{_tail(log_path)}\"\n    )\n\n\ndef write_pid_record(record: PidRecord, path: Path | None = None) -> None:\n    resolved_path: Final = path if path is not None else PID_RECORD_PATH\n    resolved_path.parent.mkdir(parents=True, exist_ok=True)\n    with open(resolved_path, \"w\") as f:\n        json.dump(\n            {\"pid\": record.pid, \"port\": record.port, \"config_path\": record.config_path, \"log_path\": record.log_path},\n            f,","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/client/cli/commands/autoroute/process.py#L83-L119","documentation":"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).","triggerScenarios":"Thrown at litellm/proxy/client/cli/commands/autoroute/process.py:101 when the library encounters an invalid state.","commonSituations":"The ephemeral proxy process crashed during startup.","solutions":["Read the logged tail lines to find why the proxy exited.","Fix the proxy config/port conflict and retry."],"exampleFix":"Check the ephemeral proxy log file shown in the error message.","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}