BerriAI/litellm · error · Exception
Not connected to DB!
Error message
Not connected to DB!
What it means
POST /customer/update raises a bare Exception('Not connected to DB!') when prisma_client is None; the surrounding handler passes it through handle_exception_on_proxy, which surfaces it to the caller as an HTTP 500. Same root cause as the standardized db_not_connected_error used elsewhere, but via a plain exception on this route.
Source
Thrown at litellm/proxy/management_endpoints/customer_endpoints.py:624
--data '{
"user_id": "user_1",
"object_permission": {
"mcp_servers": ["server_3"],
"vector_stores": ["vector_store_2", "vector_store_3"]
}
}'
See below for all params
```
"""
from litellm.proxy.proxy_server import litellm_proxy_admin_name, prisma_client
try:
data_json: Final = _STR_OBJECT_DICT.validate_python(data.json())
# get the row from db
if prisma_client is None:
raise Exception("Not connected to DB!")
# get non default values for key
non_default_values: Final = dict[str, object]()
for k, v in data_json.items():
if v is not None and v not in (
[],
{},
0,
): # models default to [], spend defaults to 0, we should not reset these values
non_default_values[k] = v
## Get end user table data ##
end_user_table_data: Final = await _typed_table(EndUserRepository(prisma_client)).find_first(
where={"user_id": data.user_id}, include={"litellm_budget_table": True}
)
if end_user_table_data is None:
raise ProxyException(View on GitHub (pinned to 77b7c6c40c)
Solutions
- Set DATABASE_URL to a postgresql:// connection string and restart the proxy
- Verify Prisma connectivity in startup logs and via another DB-backed endpoint
- Retry the update once the DB-backed health check passes
- Skip update calls on deployments intentionally running without a database
Defensive patterns
Strategy: validation
Validate before calling
import os
def update_endpoint_ready() -> bool:
return os.getenv("DATABASE_URL", "").startswith(("postgresql://", "postgres://")) Try / catch
try:
r = httpx.post(f"{base}/customer/update", json=payload, headers=headers)
except httpx.HTTPStatusError as e:
if e.response.status_code == 500 and "Not connected to DB" in e.response.text:
raise RuntimeError("proxy has no DATABASE_URL; /customer/update needs Postgres") from e
raise Prevention
- Never assume management endpoints work without a configured database
- Include DATABASE_URL in infrastructure-as-code templates so no environment boots without it
- Wrap customer-update automation with a DB readiness precondition
When it happens
Trigger: POST /customer/update with any payload on a proxy started without DATABASE_URL or whose Prisma connection never came up.
Common situations: Attempting customer updates on routing-only deployments; DATABASE_URL unset in one environment (staging) while tooling assumes parity with another (prod); DB outages after boot.
Related errors
- Postgres DB Not connected
- DB not connected. This endpoint needs a database; set DATABA
- {e}
- Failed updating customer data. User ID does not exist passed
- user_id is required, passed user_id = {data.user_id}
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/7de2f7e639525998.
Report an issue: GitHub.