BerriAI/litellm · error · HTTPException
DB not connected. This endpoint needs a database; set DATABA
Error message
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
What it means
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.
Source
Thrown at litellm/proxy/anthropic_endpoints/claude_code_endpoints/claude_code_marketplace.py:73
class _MarketplaceEntry(TypedDict, total=False):
name: str
source: object
version: str
description: str
author: object
homepage: object
keywords: object
category: object
async def _get_prisma_client() -> object:
"""Get the prisma client from proxy_server."""
from litellm.proxy.proxy_server import prisma_client
if prisma_client is None:
raise HTTPException(
status_code=500,
detail={"error": CommonProxyErrors.db_not_connected_error.value},
)
return prisma_client
@router.get(
"/claude-code/marketplace.json",
tags=["Claude Code Marketplace"],
)
async def get_marketplace():
"""
Serve marketplace.json for Claude Code plugin discovery.
This endpoint is accessed by Claude Code CLI when users run:
- claude plugin marketplace add <url>
- claude plugin install <name>@<marketplace>
View on GitHub (pinned to 77b7c6c40c)
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.
Example fix
# before litellm --config config.yaml # no database configured -> 500 'DB not connected' # after (env var) export DATABASE_URL="postgresql://user:pass@localhost:5432/litellm" litellm --config config.yaml # after (config.yaml) general: database_url: "postgresql://user:pass@localhost:5432/litellm"
Defensive patterns
Strategy: try-catch
Validate before calling
# Operator-side pre-check before starting the proxy:
import os
assert os.environ.get("DATABASE_URL", "").startswith("postgresql://"), (
"DATABASE_URL must be a postgresql:// string or /claude-code/* returns 500"
) Try / catch
import requests
try:
r = requests.get(f"{base}/claude-code/marketplace.json", timeout=10)
except requests.RequestException:
raise # transport-level failure
if r.status_code == 500 and "DB not connected" in r.text:
raise RuntimeError(
"Proxy has no database; set DATABASE_URL on the LiteLLM proxy and restart"
)
r.raise_for_status() Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- DB not connected. This endpoint needs a database; set DATABA
- Database not connected. Connect a database to your proxy - h
- Prisma client not initialized
- Database not connected. Please connect a database.
- DB not connected. This endpoint needs a database; set DATABA
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/214ad4a42a061095.
Report an issue: GitHub.