{"record":{"id":"cb40733189a2dfa7","repo":"BerriAI/litellm","slug":"not-connected-to-db-cb4073","errorCode":null,"errorMessage":"Not connected to DB!","messagePattern":"Not connected to DB!","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/proxy/management_endpoints/internal_user_endpoints.py","lineNumber":1355,"sourceCode":"        except Exception as e:  # noqa: BLE001  # a cache we cannot clear still expires; never fail the write\n            verbose_proxy_logger.warning(\"Failed to invalidate cached entitlement key %r: %s\", key, e)\n\n\nasync def _update_single_user_helper(\n    user_request: UpdateUserRequest,\n    user_api_key_dict: UserAPIKeyAuth,\n    litellm_changed_by: str | None = None,\n) -> dict[str, Any]:\n    \"\"\"\n    Helper function to update a single user.\n    Used by both user_update and bulk_user_update endpoints.\n\n    Returns the updated user data or raises an exception on failure.\n    \"\"\"\n    from litellm.proxy.proxy_server import litellm_proxy_admin_name, prisma_client\n\n    if prisma_client is None:\n        raise Exception(\"Not connected to DB!\")\n\n    if not user_request.user_id and not user_request.user_email:\n        raise ValueError(\"Either user_id or user_email must be provided\")\n\n    _check_permissions_caller_permission(\n        data=user_request,\n        user_api_key_dict=user_api_key_dict,\n    )\n\n    data_json: Final[dict] = user_request.model_dump(exclude_unset=True)\n    non_default_values = _update_internal_user_params(data_json=data_json, data=user_request)\n    _hash_password_in_dict(non_default_values)\n\n    existing_user_row: BaseModel | None = None\n    if user_request.user_id:\n        existing_user_row = await _user_table(prisma_client).find_first(where={\"user_id\": user_request.user_id})\n    elif user_request.user_email:\n        existing_user_row = await _user_table(prisma_client).find_first(where={\"user_email\": user_request.user_email})","sourceCodeStart":1337,"sourceCodeEnd":1373,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_endpoints/internal_user_endpoints.py#L1337-L1373","documentation":"_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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nPOST /user/update {\"user_id\": \"u1\", \"user_alias\": \"x\"}\n# 400 ProxyException: Authentication Error, Not connected to DB!\n\n# after: config.yaml\ngeneral_settings:\n  database_url: postgresql://user:pass@host:5432/litellm\n# restart, retry -> 200","handlingStrategy":"validation","validationCode":"import requests\n\ndef db_ready(base_url: str, admin_key: str) -> bool:\n    r = requests.get(f\"{base_url}/health/liveliness\",\n                     headers={\"Authorization\": f\"Bearer {admin_key}\"}, timeout=10)\n    return r.ok and r.json().get(\"litellm_database\", \"\") != \"\"","typeGuard":null,"tryCatchPattern":"except requests.HTTPError as e:\n    body = e.response.text if e.response is not None else \"\"\n    if \"Not connected to DB!\" in body:\n        raise ConfigError(\"DATABASE_URL missing - user updates need Postgres\") from e\n    raise","preventionTips":["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"],"tags":["litellm","database","user-management","proxy-exception"],"backgroundTag":"database-not-connected","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}