{"record":{"id":"39c6bca2adfae6e7","repo":"BerriAI/litellm","slug":"db-not-connected-this-endpoint-needs-a-database-39c6bc","errorCode":null,"errorMessage":"DB not connected. This endpoint needs a database; set DATABASE_URL to a PostgreSQL connection string (postgresql://...) to enable it. See https://docs.litellm.ai/docs/proxy/virtual_keys","messagePattern":"DB not connected\\. This endpoint needs a database; set DATABASE_URL to a PostgreSQL connection string \\(postgresql://\\.\\.\\.\\) to enable it\\. See https://docs\\.litellm\\.ai/docs/proxy/virtual_keys","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"critical","filePath":"enterprise/litellm_enterprise/proxy/management_endpoints/project_endpoints.py","lineNumber":363,"sourceCode":"            raise HTTPException(\n                status_code=403,\n                detail={\n                    \"error\": \"Project management is an enterprise feature. \" + CommonProxyErrors.not_premium_user.value\n                },\n            )\n\n        # ADD METADATA FIELDS\n        for field in LiteLLM_ManagementEndpoint_MetadataFields_Premium:\n            if getattr(data, field, None) is not None:\n                _set_object_metadata_field(\n                    object_data=data,\n                    field_name=field,\n                    value=getattr(data, field),\n                )\n                delattr(data, field)\n\n        if prisma_client is None:\n            raise HTTPException(\n                status_code=500,\n                detail={\"error\": CommonProxyErrors.db_not_connected_error.value},\n            )\n\n        # Validate team exists and get team object with budget\n        team_object = await _validate_team_exists(team_id=data.team_id, prisma_client=prisma_client)\n\n        # Validate project limits against team limits\n        _check_team_project_limits(\n            team_object=LiteLLM_TeamTable.model_validate(team_object.model_dump()),\n            data=data,\n        )\n\n        # Check if user has permission to create projects for this team\n        # only team admins can create projects for their team\n        has_permission = await _check_user_permission_for_project(\n            user_api_key_dict=user_api_key_dict,\n            team_id=data.team_id,","sourceCodeStart":345,"sourceCodeEnd":381,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/enterprise/litellm_enterprise/proxy/management_endpoints/project_endpoints.py#L345-L381","documentation":"Project endpoints persist state in PostgreSQL via Prisma; if the proxy booted without a DATABASE_URL, prisma_client is None and POST /project/new aborts with HTTP 500 and CommonProxyErrors.db_not_connected_error. This is a server-side configuration gap, not a bad request.","triggerScenarios":"POST /project/new against a proxy started without DATABASE_URL (e.g. config-only mode with just a YAML of models), or where the DB connection failed at startup leaving prisma_client unset.","commonSituations":"Evaluating the proxy with a static config first and later trying management endpoints, DATABASE_URL typo'd or pointing at an unreachable Postgres, or forgetting to pass the env var into Docker.","solutions":["Set DATABASE_URL to a valid PostgreSQL connection string (postgresql://user:pass@host:5432/db) and restart the proxy","Confirm startup logs show the Prisma client connected before retrying","If running in Docker/K8s, verify the env var is injected into the proxy container itself"],"exampleFix":"# before\nlitellm --config config.yaml  # no DATABASE_URL\n# after\nexport DATABASE_URL=postgresql://postgres:postgres@localhost:5432/litellm\nlitellm --config config.yaml","handlingStrategy":"try-catch","validationCode":"health = await client.get('/health/liveliness')\n# or check that key management endpoints work, e.g. GET /key/list, as a DB proxy check\n# DB presence is server-side; best client-side proxy is an admin health endpoint","typeGuard":null,"tryCatchPattern":"catch (e) {\n  if (e.status === 500 && /DB not connected/.test(e.body?.detail?.error ?? '')) {\n    throw new Error('Proxy has no DATABASE_URL configured; set it and restart the proxy');\n  }\n  throw e;\n}","preventionTips":["Always set DATABASE_URL when deploying with management endpoints; treat it as mandatory for enterprise features","Include a DB-backed health check in readiness probes so traffic only routes to DB-connected replicas"],"tags":["litellm","database","prisma","configuration","http-500"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}