BerriAI/litellm · error · Exception

Database not connected. Connect a database to your proxy - h

Error message

Database not connected. Connect a database to your proxy - https://docs.litellm.ai/docs/simple_proxy#managing-auth---virtual-keys

What it means

GET /user/info requires a connected Prisma database. If the proxy started without one (prisma_client is None because general_settings.database_url / DATABASE_URL was never set or Prisma failed to connect), the handler raises a plain Exception whose message links to the virtual-keys docs. Because it is not an HTTPException, FastAPI surfaces it as HTTP 500 with this text in the response body.

Source

Thrown at litellm/proxy/management_endpoints/internal_user_endpoints.py:874

    Note: To get all users (+pagination), use `/user/list` endpoint.


    Use this to get user information. (user row + all user key info)

    Example request
    ```
    curl -X GET 'http://localhost:4000/user/info?user_id=krrish7%40berri.ai' \
    --header 'Authorization: Bearer sk-1234'
    ```
    """
    from litellm.proxy.proxy_server import prisma_client

    try:
        user_id = _normalize_user_info_user_id(request=request, user_id=user_id)
        _enforce_user_info_access(user_id=user_id, user_api_key_dict=user_api_key_dict)

        if prisma_client is None:
            raise Exception(
                "Database not connected. Connect a database to your proxy - https://docs.litellm.ai/docs/simple_proxy#managing-auth---virtual-keys"
            )
        if user_id is None and _user_has_admin_view(user_api_key_dict):
            return await _get_user_info_for_proxy_admin(user_api_key_dict=user_api_key_dict)
        elif user_id is None:
            user_id = user_api_key_dict.user_id
        ## GET USER ROW ##

        user_info = None
        if user_id is not None:
            user_info = await prisma_client.get_data(user_id=user_id)

        if user_info is None:
            raise HTTPException(
                status_code=404,
                detail=f"User {user_id} not found",
            )

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Set a Postgres URL under general_settings.database_url in config.yaml (or the DATABASE_URL env var) and restart the proxy
  2. Check startup logs for Prisma connection errors; the URL must be postgresql://... with valid credentials
  3. Verify the DB path works via GET /health/liveliness or GET /user/list before retrying

Example fix

# before: config.yaml with no database
model_list:
  - model_name: gpt-4o
    litellm_params:
      model: openai/gpt-4o

# after: add the database
 general_settings:
  database_url: postgresql://user:pass@host:5432/litellm
Defensive patterns

Strategy: validation

Validate before calling

import requests

def db_ready(base_url: str, admin_key: str) -> bool:
    r = requests.get(f"{base_url}/health/liveliness",
                     headers={"Authorization": f"Bearer {admin_key}"}, timeout=10)
    return r.ok and r.json().get("litellm_database", "") != ""

Try / catch

except requests.HTTPError as e:
    if e.response is not None and e.response.status_code == 500 and "Database not connected" in e.response.text:
        raise ConfigError("Set general_settings.database_url and restart the proxy") from e
    raise

Prevention

When it happens

Trigger: GET /user/info against a proxy whose config.yaml only defines model_list (no database_url), with DATABASE_URL unset, or whose Prisma connection failed during startup.

Common situations: Quick local tests without Postgres; docker/k8s deployments missing the DATABASE_URL env var; typos in the connection string; calling user-management endpoints before DB setup.

Related errors


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