{"record":{"id":"214ad4a42a061095","repo":"BerriAI/litellm","slug":"db-not-connected-this-endpoint-needs-a-database-214ad4","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":"error","filePath":"litellm/proxy/anthropic_endpoints/claude_code_endpoints/claude_code_marketplace.py","lineNumber":73,"sourceCode":"\n\nclass _MarketplaceEntry(TypedDict, total=False):\n    name: str\n    source: object\n    version: str\n    description: str\n    author: object\n    homepage: object\n    keywords: object\n    category: object\n\n\nasync def _get_prisma_client() -> object:\n    \"\"\"Get the prisma client from proxy_server.\"\"\"\n    from litellm.proxy.proxy_server import prisma_client\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    return prisma_client\n\n\n@router.get(\n    \"/claude-code/marketplace.json\",\n    tags=[\"Claude Code Marketplace\"],\n)\nasync def get_marketplace():\n    \"\"\"\n    Serve marketplace.json for Claude Code plugin discovery.\n\n    This endpoint is accessed by Claude Code CLI when users run:\n    - claude plugin marketplace add <url>\n    - claude plugin install <name>@<marketplace>\n","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/anthropic_endpoints/claude_code_endpoints/claude_code_marketplace.py#L55-L91","documentation":"LiteLLM proxy raises this 500 from _get_prisma_client() when the global prisma_client is None, meaning the proxy process started without any PostgreSQL connection configured. Every Claude Code marketplace endpoint (/claude-code/marketplace.json, /claude-code/plugins and all sub-routes) persists plugin metadata in Postgres via Prisma, so they hard-require DATABASE_URL. The error text points at the virtual-keys docs because the database is a proxy-wide feature, not specific to this endpoint.","triggerScenarios":"Calling GET /claude-code/marketplace.json or any /claude-code/plugins* route on a proxy started with only `litellm --config config.yaml` (or `litellm --model ...`) where neither the DATABASE_URL env var nor `general.database_url` in the config is set. Also happens when the env var is set in a different shell/container than the one running the proxy, so the proxy process never sees it.","commonSituations":"Trying out the Claude Code plugin marketplace on a local dev proxy that was previously started without a DB; running the proxy in Docker/Kubernetes and forgetting to pass DATABASE_URL through env or env_file; setting database_url under the wrong config section so LiteLLM ignores it; upgrading LiteLLM and assuming the marketplace works without the DB feature.","solutions":["Set DATABASE_URL to a valid PostgreSQL connection string, e.g. export DATABASE_URL=\"postgresql://user:pass@host:5432/litellm\", or add `database_url:` under the `general:` section of your proxy config YAML, then restart the proxy so Prisma connects and runs migrations.","If running in Docker, verify the variable actually reaches the container: `docker exec <container> printenv DATABASE_URL` (check name, not value) and fix the compose/env_file wiring if missing.","Confirm the DB is reachable from the proxy host (psql/<host>:5432) and that credentials are valid; a bad connection string can also leave prisma_client unset.","After restart, re-hit the endpoint; if migrations created the plugin tables, GET /claude-code/plugins (with a valid virtual key) should return an empty list instead of this error."],"exampleFix":"# before\nlitellm --config config.yaml   # no database configured -> 500 'DB not connected'\n\n# after (env var)\nexport DATABASE_URL=\"postgresql://user:pass@localhost:5432/litellm\"\nlitellm --config config.yaml\n\n# after (config.yaml)\ngeneral:\n  database_url: \"postgresql://user:pass@localhost:5432/litellm\"","handlingStrategy":"try-catch","validationCode":"# Operator-side pre-check before starting the proxy:\nimport os\nassert os.environ.get(\"DATABASE_URL\", \"\").startswith(\"postgresql://\"), (\n    \"DATABASE_URL must be a postgresql:// string or /claude-code/* returns 500\"\n)","typeGuard":null,"tryCatchPattern":"import requests\ntry:\n    r = requests.get(f\"{base}/claude-code/marketplace.json\", timeout=10)\nexcept requests.RequestException:\n    raise  # transport-level failure\nif r.status_code == 500 and \"DB not connected\" in r.text:\n    raise RuntimeError(\n        \"Proxy has no database; set DATABASE_URL on the LiteLLM proxy and restart\"\n    )\nr.raise_for_status()","preventionTips":["Always configure DATABASE_URL (or general.database_url in the config YAML) when deploying a proxy that serves the Claude Code marketplace.","In Docker/K8s, assert the env var is present in the container before startup.","Smoke-test one DB-backed endpoint after proxy startup to fail fast in deploy pipelines."],"tags":["litellm-proxy","database","postgres","prisma","configuration","claude-code-marketplace"],"backgroundTag":"database-not-connected","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}