BerriAI/litellm · critical · Exception
No DB Connected. See - https://docs.litellm.ai/docs/proxy/vi
Error message
No DB Connected. See - https://docs.litellm.ai/docs/proxy/virtual_keys
What it means
Raised by get_team_object when a team row must be resolved but prisma_client is None. Team-scoped keys, team budgets and team model access all read LiteLLM_TeamTable, so any team_id on a key makes the database mandatory.
Source
Thrown at litellm/proxy/auth/auth_checks.py:2543
team_id: str,
prisma_client: PrismaClient | None,
user_api_key_cache: UserApiKeyCache,
parent_otel_span: Span | None = None,
proxy_logging_obj: ProxyLogging | None = None,
check_cache_only: bool | None = None,
check_db_only: bool | None = None,
team_id_upsert: bool | None = None,
) -> LiteLLM_TeamTableCachedObj:
"""
- Check if team id in proxy Team Table
- if valid, return LiteLLM_TeamTable object with defined limits
- if not, then raise an error
Raises:
- HTTPException: If team doesn't exist in db or cache (status_code=404)
"""
if prisma_client is None:
raise Exception("No DB Connected. See - https://docs.litellm.ai/docs/proxy/virtual_keys")
# check if in cache
key: Final = f"team_id:{team_id}"
if not check_db_only:
cached_team_obj: Final = await _get_team_object_from_cache(
key=key,
proxy_logging_obj=proxy_logging_obj,
user_api_key_cache=user_api_key_cache,
parent_otel_span=parent_otel_span,
)
if cached_team_obj is not None:
return cached_team_obj
if check_cache_only:
raise HTTPException(
status_code=404,View on GitHub (pinned to 77b7c6c40c)
Solutions
- Set DATABASE_URL and restart so prisma_client is initialized
- Run prisma migrations to create the team tables
- If running DB-less intentionally, remove team_id from keys
Example fix
# before litellm --config config.yaml # teams configured, no DB # after DATABASE_URL="postgresql://user:pass@host:5432/litellm" litellm --config config.yaml
Defensive patterns
Strategy: validation
Validate before calling
# operator preflight: team-scoped keys require the DB
import os
if any(k.get("team_id") for k in keys) and not os.getenv("DATABASE_URL"):
raise SystemExit("team-scoped keys require DATABASE_URL") Try / catch
try:
resp = client.chat.completions.create(**payload)
except Exception as e:
if "No DB Connected" in str(e):
raise RuntimeError("proxy misconfigured: DATABASE_URL missing") from e
raise Prevention
- Any key with team_id implies a database is required - configure it at deploy time
- Include DATABASE_URL in infrastructure templates and helm values by default
- Validate prisma connectivity in a post-deploy health check
When it happens
Trigger: A key with a team_id authenticates while the proxy runs without DATABASE_URL; even cache-first paths raise here because the DB fallback is structurally unavailable.
Common situations: Teams/virtual-key features enabled on a deployment that never configured a database; DATABASE_URL dropped during a migration to a new orchestrator.
Related errors
- No db connected
- DB not connected. This endpoint needs a database; set DATABA
- Prisma client is not initialized. Database connection requir
- DB not connected. This endpoint needs a database; set DATABA
- Prisma client not initialized
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/69a7ce30d64bc715.
Report an issue: GitHub.