BerriAI/litellm · error · HTTPException

Server misconfigured: no database connection

Error message

Server misconfigured: no database connection

What it means

HTTP 500 in the MCP user-reload path: the handler needed the proxy database (Prisma client) but it is not initialized — typically a test or misconfigured server running without a DB — so the live user cannot be re-fetched.

Source

Thrown at litellm/proxy/_experimental/mcp_server/auth/user_api_key_auth_mcp.py:918

    @staticmethod
    async def _reload_admitted_user(user_id: str) -> UserAPIKeyAuth:
        """Reload the live user an interactively-minted envelope references and admit them as themselves.

        The user's own object permission and ``org_id`` ride on the returned ``UserAPIKeyAuth``, and the
        SAME ``get_allowed_mcp_servers`` the key path uses gates the request. The ``mcp_admitted_user_subject``
        marker (set below) makes that resolver union the servers the user reaches through ANY of their teams
        on top of these direct grants, each source bounded by ITS OWN org, so a user spanning organizations
        cannot leak one org's servers past another's ceiling.

        Error handling: ``get_user_object`` catches every DB failure and re-raises a bare ``ValueError``, so a
        missing user and a real outage look identical (the cause survives only as ``__context__``).
        ``_raise_503_if_db_unavailable`` walks the cause chain so an outage stays a retryable 503 while any
        other failure fails closed as 401, not an opaque 500; the object-permission load shares that boundary."""
        from litellm.proxy.auth.auth_checks import get_object_permission, get_user_object
        from litellm.proxy.proxy_server import prisma_client, user_api_key_cache

        if prisma_client is None:
            raise HTTPException(status_code=500, detail="Server misconfigured: no database connection")
        try:
            user_object: Final = await get_user_object(
                user_id=user_id,
                prisma_client=prisma_client,
                user_api_key_cache=user_api_key_cache,
                user_id_upsert=False,
            )
            # Resolve the user's own MCP object permission (get_user_object does not load it) so the shared
            # get_allowed_mcp_servers can grant the user their litellm-granted servers. Reuses the same
            # get_object_permission resolver the key and team paths use; no permission logic is duplicated.
            object_permission = user_object.object_permission if user_object is not None else None
            if user_object is not None and object_permission is None and user_object.object_permission_id:
                object_permission = await get_object_permission(
                    object_permission_id=user_object.object_permission_id,
                    prisma_client=prisma_client,
                    user_api_key_cache=user_api_key_cache,
                )
        except (ProxyException, HTTPException):

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Configure DATABASE_URL so the proxy can verify credentials.

Example fix

export DATABASE_URL='postgresql://user:pass@host/db'
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/_experimental/mcp_server/auth/user_api_key_auth_mcp.py:918 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/7c9eb22ea6dd7c41. Report an issue: GitHub.