{"record":{"id":"cc5b15a65f34c909","repo":"BerriAI/litellm","slug":"iam-token-db-auth-is-enabled-and-database-host-rea","errorCode":null,"errorMessage":"IAM_TOKEN_DB_AUTH is enabled and DATABASE_HOST_READ_REPLICA is set, but the reader could not resolve: {', '.join(missing)} (no *_READ_REPLICA value and no writer fallback). Set the reader fields or the writer defaults.","messagePattern":"IAM_TOKEN_DB_AUTH is enabled and DATABASE_HOST_READ_REPLICA is set, but the reader could not resolve: (.+?) \\(no \\*_READ_REPLICA value and no writer fallback\\)\\. Set the reader fields or the writer defaults\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"litellm/proxy/db/db_url_settings.py","lineNumber":202,"sourceCode":"\n        host: Final = self.database_host_read_replica\n        port: Final = self.database_port_read_replica or self.database_port\n        user = self.database_user_read_replica or self.database_user\n        name = self.database_name_read_replica or self.database_name\n        schema: Final = self.database_schema_read_replica or self.database_schema\n        password: Final = self.database_password_read_replica or self.database_password\n\n        if self.iam_token_db_auth:\n            missing: Final = [\n                env\n                for env, val in (\n                    (\"DATABASE_USER[_READ_REPLICA]\", user),\n                    (\"DATABASE_NAME[_READ_REPLICA]\", name),\n                )\n                if not val\n            ]\n            if missing:\n                raise RuntimeError(\n                    \"IAM_TOKEN_DB_AUTH is enabled and DATABASE_HOST_READ_REPLICA \"\n                    \"is set, but the reader could not resolve: \"\n                    f\"{', '.join(missing)} (no *_READ_REPLICA value and no \"\n                    \"writer fallback). Set the reader fields or the writer \"\n                    \"defaults.\"\n                )\n            user = cast(str, user)\n            name = cast(str, name)\n            token: Final = rds_iam_token.generate_iam_auth_token(db_host=host, db_port=port, db_user=user)\n            url = f\"postgresql://{user}:{token}@{host}:{port}/{name}\"\n            if schema:\n                url += f\"?schema={schema}\"\n            return url\n\n        if user and name:\n            return self._password_url(\n                user=user,\n                password=password,","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/db/db_url_settings.py#L184-L220","documentation":"Error \"IAM_TOKEN_DB_AUTH is enabled and DATABASE_HOST_READ_REPLICA is set, but the reader could not resolve: {', '.join(missing)} (no *_READ_REPLICA value and no writer fallback). Set the reader fields or the writer defaults.\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/proxy/db/db_url_settings.py:202 when the library encounters an invalid state.","commonSituations":"IAM_TOKEN_DB_AUTH with a read replica configured, but reader fields and writer fallbacks are both missing.","solutions":["Set the *_READ_REPLICA variants of the DB env vars, or set the writer defaults so the reader can fall back."],"exampleFix":"export DATABASE_HOST_READ_REPLICA=... DATABASE_USER_READ_REPLICA=...","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}