BerriAI/litellm · error · HTTPException
Invalid or missing X-Drain-Token
Error message
Invalid or missing X-Drain-Token
What it means
Error "Invalid or missing X-Drain-Token" thrown in BerriAI/litellm.
Source
Thrown at litellm/proxy/health_endpoints/_health_endpoints.py:1598
if env_token:
return env_token
return None
def _authorize_drain_request(request: Request) -> None:
"""
Reject /health/drain calls that don't carry the configured X-Drain-Token.
When no token is configured the endpoint is treated as already opted-in
(the ``enable_drain_endpoint`` flag is the only gate). Comparison uses
``secrets.compare_digest`` to avoid timing leaks.
"""
expected: Final = _drain_endpoint_token()
if expected is None:
return
supplied: Final = request.headers.get("x-drain-token") or ""
if not secrets.compare_digest(supplied, expected):
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Invalid or missing X-Drain-Token",
)
async def _resolve_public_readiness_db(response: Response) -> str:
"""
Return the db status string for the public probe and flip the response to
503 when a configured DB is unreachable. Mirrors the legacy values:
"Not connected" (no DB configured), "connected", "disconnected".
"""
from litellm.proxy.proxy_server import prisma_client
if prisma_client is None:
return "Not connected"
db_health_status: Final = await _db_health_readiness_check()
if db_health_status["status"] != "connected":View on GitHub (pinned to 77b7c6c40c)
Solutions
- Send the correct drain token in the X-Drain-Token header.
- Verify the drain token configured on the proxy matches the one used by the client.
When it happens
Trigger: Thrown at litellm/proxy/health_endpoints/_health_endpoints.py:1598 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/e56a315277ff1202.
Report an issue: GitHub.