BerriAI/litellm · error · Exception
Not connected to DB!
Error message
Not connected to DB!
What it means
_update_single_user_helper backs POST /user/update and the bulk update endpoints. If prisma_client is None it raises a plain Exception 'Not connected to DB!'. The /user/update handler then wraps it into a ProxyException reading 'Authentication Error, Not connected to DB!' - misleading classification, but the root cause is simply that no database is configured.
Source
Thrown at litellm/proxy/management_endpoints/internal_user_endpoints.py:1355
except Exception as e: # noqa: BLE001 # a cache we cannot clear still expires; never fail the write
verbose_proxy_logger.warning("Failed to invalidate cached entitlement key %r: %s", key, e)
async def _update_single_user_helper(
user_request: UpdateUserRequest,
user_api_key_dict: UserAPIKeyAuth,
litellm_changed_by: str | None = None,
) -> dict[str, Any]:
"""
Helper function to update a single user.
Used by both user_update and bulk_user_update endpoints.
Returns the updated user data or raises an exception on failure.
"""
from litellm.proxy.proxy_server import litellm_proxy_admin_name, prisma_client
if prisma_client is None:
raise Exception("Not connected to DB!")
if not user_request.user_id and not user_request.user_email:
raise ValueError("Either user_id or user_email must be provided")
_check_permissions_caller_permission(
data=user_request,
user_api_key_dict=user_api_key_dict,
)
data_json: Final[dict] = user_request.model_dump(exclude_unset=True)
non_default_values = _update_internal_user_params(data_json=data_json, data=user_request)
_hash_password_in_dict(non_default_values)
existing_user_row: BaseModel | None = None
if user_request.user_id:
existing_user_row = await _user_table(prisma_client).find_first(where={"user_id": user_request.user_id})
elif user_request.user_email:
existing_user_row = await _user_table(prisma_client).find_first(where={"user_email": user_request.user_email})View on GitHub (pinned to 77b7c6c40c)
Solutions
- Set general_settings.database_url (postgresql://...) or DATABASE_URL and restart the proxy
- Grep the proxy logs for 'Not connected to DB!' - the handler also logs the full exception and traceback at exception level
- Confirm the DB path works via GET /user/list before retrying the update
Example fix
# before
POST /user/update {"user_id": "u1", "user_alias": "x"}
# 400 ProxyException: Authentication Error, Not connected to DB!
# after: config.yaml
general_settings:
database_url: postgresql://user:pass@host:5432/litellm
# restart, retry -> 200 Defensive patterns
Strategy: validation
Validate before calling
import requests
def db_ready(base_url: str, admin_key: str) -> bool:
r = requests.get(f"{base_url}/health/liveliness",
headers={"Authorization": f"Bearer {admin_key}"}, timeout=10)
return r.ok and r.json().get("litellm_database", "") != "" Try / catch
except requests.HTTPError as e:
body = e.response.text if e.response is not None else ""
if "Not connected to DB!" in body:
raise ConfigError("DATABASE_URL missing - user updates need Postgres") from e
raise Prevention
- Never deploy user-management flows without a verified DB connection
- Watch logs for 'Not connected to DB!' - the ProxyException 'Authentication Error' prefix misclassifies it
- Add /health/liveliness checks to deploy pipelines and CI
When it happens
Trigger: POST /user/update or POST /user/bulk_update against a proxy started without general_settings.database_url / DATABASE_URL, or whose Prisma connection failed at startup.
Common situations: Running the proxy config-less for model routing only; missing DATABASE_URL env in the job's container; the auth-error wrapping sends developers chasing the wrong problem.
Related errors
- Failed to update user
- f"Authentication Error({e})"
- "Authentication Error, " + str(e)
- str(e)
- 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/cb40733189a2dfa7.
Report an issue: GitHub.