{"record":{"id":"016d1be7bed4ced7","repo":"BerriAI/litellm","slug":"database-not-connected-connect-a-database-to-your-016d1b","errorCode":null,"errorMessage":"Database not connected. Connect a database to your proxy - https://docs.litellm.ai/docs/simple_proxy#managing-auth---virtual-keys","messagePattern":"Database not connected\\. Connect a database to your proxy - https://docs\\.litellm\\.ai/docs/simple_proxy#managing-auth---virtual-keys","errorType":"exception","errorClass":"Exception","httpStatus":500,"severity":"error","filePath":"litellm/proxy/management_endpoints/internal_user_endpoints.py","lineNumber":874,"sourceCode":"    Note: To get all users (+pagination), use `/user/list` endpoint.\n\n\n    Use this to get user information. (user row + all user key info)\n\n    Example request\n    ```\n    curl -X GET 'http://localhost:4000/user/info?user_id=krrish7%40berri.ai' \\\n    --header 'Authorization: Bearer sk-1234'\n    ```\n    \"\"\"\n    from litellm.proxy.proxy_server import prisma_client\n\n    try:\n        user_id = _normalize_user_info_user_id(request=request, user_id=user_id)\n        _enforce_user_info_access(user_id=user_id, user_api_key_dict=user_api_key_dict)\n\n        if prisma_client is None:\n            raise Exception(\n                \"Database not connected. Connect a database to your proxy - https://docs.litellm.ai/docs/simple_proxy#managing-auth---virtual-keys\"\n            )\n        if user_id is None and _user_has_admin_view(user_api_key_dict):\n            return await _get_user_info_for_proxy_admin(user_api_key_dict=user_api_key_dict)\n        elif user_id is None:\n            user_id = user_api_key_dict.user_id\n        ## GET USER ROW ##\n\n        user_info = None\n        if user_id is not None:\n            user_info = await prisma_client.get_data(user_id=user_id)\n\n        if user_info is None:\n            raise HTTPException(\n                status_code=404,\n                detail=f\"User {user_id} not found\",\n            )\n","sourceCodeStart":856,"sourceCodeEnd":892,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_endpoints/internal_user_endpoints.py#L856-L892","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set a Postgres URL under general_settings.database_url in config.yaml (or the DATABASE_URL env var) and restart the proxy","Check startup logs for Prisma connection errors; the URL must be postgresql://... with valid credentials","Verify the DB path works via GET /health/liveliness or GET /user/list before retrying"],"exampleFix":"# before: config.yaml with no database\nmodel_list:\n  - model_name: gpt-4o\n    litellm_params:\n      model: openai/gpt-4o\n\n# after: add the database\n general_settings:\n  database_url: postgresql://user:pass@host:5432/litellm","handlingStrategy":"validation","validationCode":"import requests\n\ndef db_ready(base_url: str, admin_key: str) -> bool:\n    r = requests.get(f\"{base_url}/health/liveliness\",\n                     headers={\"Authorization\": f\"Bearer {admin_key}\"}, timeout=10)\n    return r.ok and r.json().get(\"litellm_database\", \"\") != \"\"","typeGuard":null,"tryCatchPattern":"except requests.HTTPError as e:\n    if e.response is not None and e.response.status_code == 500 and \"Database not connected\" in e.response.text:\n        raise ConfigError(\"Set general_settings.database_url and restart the proxy\") from e\n    raise","preventionTips":["Treat DATABASE_URL as mandatory for any user/key-management endpoint","Add a readiness probe on /health before sending management traffic","Keep database config in one place (config.yaml general_settings) instead of ad-hoc env overrides"],"tags":["litellm","database","prisma","postgres","config"],"backgroundTag":"database-not-connected","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}