{"record":{"id":"28211cd57035d11b","repo":"BerriAI/litellm","slug":"no-db-connected","errorCode":null,"errorMessage":"No db connected","messagePattern":"No db connected","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"litellm/proxy/auth/auth_checks.py","lineNumber":1522,"sourceCode":"    If end user exists but has no budget_id, applies the default budget\n    (if configured via litellm.max_end_user_budget_id).\n\n    Args:\n        end_user_id: The ID of the end user\n        prisma_client: Database client instance\n        user_api_key_cache: Cache for storing/retrieving data\n        route: The request route\n        parent_otel_span: Optional OpenTelemetry span for tracing\n        proxy_logging_obj: Optional proxy logging object\n        token_end_user_max_budget: ``valid_token.end_user_max_budget``, when the caller holds a\n            token. Budget enforcement reads the row's spend, so a row that restricts nothing on\n            its own must still be loaded when the token carries a budget for it.\n\n    Returns:\n        LiteLLM_EndUserTable if found, None otherwise\n    \"\"\"\n    if prisma_client is None:\n        raise Exception(\"No db connected\")\n\n    if end_user_id is None:\n        return None\n\n    _key: Final = end_user_cache_key(end_user_id)\n\n    # Check cache first\n    cached_user_obj: Final = await user_api_key_cache.async_get_cache(\n        key=_key,\n        model_type=LiteLLM_EndUserTable,\n    )\n    if cached_user_obj is not None:\n        return_obj = cached_user_obj\n        # Apply default budget if needed\n        return_obj = await _apply_default_budget_to_end_user(\n            end_user_obj=return_obj,\n            prisma_client=prisma_client,\n            user_api_key_cache=user_api_key_cache,","sourceCodeStart":1504,"sourceCodeEnd":1540,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/auth/auth_checks.py#L1504-L1540","documentation":"Raised by get_end_user_object when an end-user row must be loaded (for example the token carries end_user_max_budget) but prisma_client is None - the proxy started without a database because DATABASE_URL was never set. End-user budgets and trackers are DB-backed features that cannot run in DB-less mode.","triggerScenarios":"A request identifies an end user (X-Litellm-End-User header or end-user param) together with a key that sets end_user_max_budget, while the proxy has no DATABASE_URL configured.","commonSituations":"Running the proxy from a single config.yaml without a database, then attaching budgeted virtual keys or end-user limits; forgetting DATABASE_URL in docker-compose/k8s after adding virtual-key features.","solutions":["Set DATABASE_URL on the proxy and start it (litellm --config config.yaml --database_url $DATABASE_URL), then run prisma migrations","Until a DB exists, stop using end-user budgets / keys with end_user_max_budget","Confirm connectivity via the proxy health endpoints once started"],"exampleFix":"# before\ndocker run litellm/litellm --config config.yaml  # no DATABASE_URL\n\n# after\ndocker run -e DATABASE_URL=\"postgresql://user:pass@host:5432/litellm\" \\\n  litellm/litellm --config config.yaml","handlingStrategy":"validation","validationCode":"# operator preflight: refuse to start DB-dependent features without a DB\nimport os\n\nif not os.getenv(\"DATABASE_URL\"):\n    raise SystemExit(\n        \"end-user budgets / virtual keys require DATABASE_URL - unset them or configure the DB\"\n    )","typeGuard":null,"tryCatchPattern":"try:\n    resp = client.chat.completions.create(**payload)\nexcept Exception as e:\n    if \"No db connected\" in str(e):\n        raise RuntimeError(\"proxy misconfigured: DATABASE_URL missing\") from e\n    raise","preventionTips":["Treat DATABASE_URL as mandatory the moment any budgeted key or end-user tracking is used","Add a startup check that fails fast when prisma_client is None but DB-backed features are configured","Exercise /health endpoints after deploy to confirm DB connectivity"],"tags":["database","prisma","config","end-user","litellm-proxy"],"backgroundTag":"database-not-connected","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}