{"id":"86af59153258da13","repo":"redis/redis-py","slug":"database-health-check-url-is-not-set-please-check","errorCode":null,"errorMessage":"Database health check url is not set. Please check DatabaseConfig for the current database.","messagePattern":"Database health check url is not set\\. Please check DatabaseConfig for the current database\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"redis/asyncio/multidb/healthcheck.py","lineNumber":470,"sourceCode":"        )\n        self._rest_api_port = rest_api_port\n        self._lag_aware_tolerance = lag_aware_tolerance\n        super().__init__(\n            health_check_probes=health_check_probes,\n            health_check_delay=health_check_delay,\n            health_check_timeout=health_check_timeout,\n        )\n\n    async def check_health(self, database, hc_client: AsyncRedisClientT) -> bool:\n        \"\"\"\n        Check database health via Redis Enterprise REST API.\n\n        Note: The client parameter is not used for this health check as it\n        relies on the REST API instead of Redis protocol. The client is\n        accepted for interface compatibility.\n        \"\"\"\n        if database.health_check_url is None:\n            raise ValueError(\n                \"Database health check url is not set. Please check DatabaseConfig for the current database.\"\n            )\n\n        if isinstance(database.client, (AsyncRedis, SyncRedis)):\n            db_host = database.client.get_connection_kwargs()[\"host\"]\n        else:\n            # Cluster client\n            db_host = database.client.get_nodes()[0].host\n\n        base_url = f\"{database.health_check_url}:{self._rest_api_port}\"\n        self._http_client.client.base_url = base_url\n\n        # Find bdb matching to the current database host\n        matching_bdb = None\n        for bdb in await self._http_client.get(\"/v1/bdbs\"):\n            for endpoint in bdb[\"endpoints\"]:\n                if endpoint[\"dns_name\"] == db_host:\n                    matching_bdb = bdb","sourceCodeStart":452,"sourceCodeEnd":488,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/asyncio/multidb/healthcheck.py#L452-L488","documentation":"Raised by LagAwareHealthCheck.check_health (redis/asyncio/multidb/healthcheck.py:470) when database.health_check_url is None. The lag-aware policy queries the Redis Enterprise REST API at that URL, so an unset URL makes the check impossible. This is a configuration defect in the DatabaseConfig, not a runtime network failure.","triggerScenarios":"Configuring a multidb database with the LagAwareHealthCheck policy but omitting health_check_url on its DatabaseConfig; reusing a DatabaseConfig built for PingHealthCheck (which needs no URL) against a LagAwareHealthCheck.","commonSituations":"Mixing health-check policies across databases without updating each DatabaseConfig; pointing a LagAwareHealthCheck at a standalone (non-Enterprise) Redis that has no REST API URL.","solutions":["Set health_check_url on the DatabaseConfig to the Redis Enterprise REST API base URL (e.g. https://cluster-host).","If the target is not Redis Enterprise, switch to PingHealthCheck which uses the Redis protocol and needs no URL.","Audit every DatabaseConfig paired with a LagAwareHealthCheck to confirm health_check_url is populated."],"exampleFix":"# before\ndb = DatabaseConfig(client=..., health_check_policy=HealthCheckPolicies.HEALTHY_ALL)\n# health_check_url omitted -> LagAwareHealthCheck fails\n# after\ndb = DatabaseConfig(client=..., health_check_url=\"https://rec-cluster.example.com\")","handlingStrategy":"validation","validationCode":"if isinstance(hc, LagAwareHealthCheck) and not getattr(db_config, 'health_check_url', None):\n    raise ConfigError('LagAwareHealthCheck requires DatabaseConfig.health_check_url')","typeGuard":"def needs_rest_url(policy) -> bool:\n    from redis.asyncio.multidb.healthcheck import LagAwareHealthCheck, HealthCheckPolicies\n    cls = policy.value if isinstance(policy, HealthCheckPolicies) else policy\n    return isinstance(cls, type) and issubclass(cls, LagAwareHealthCheck)","tryCatchPattern":"try:\n    await health_check.check_health(database, client)\nexcept ValueError as e:\n    logger.error('health check misconfigured: %s', e)\n    mark_database_unhealthy(database)","preventionTips":["Pair each LagAwareHealthCheck with a DatabaseConfig that sets health_check_url.","Use PingHealthCheck for non-Enterprise Redis."],"tags":["config","healthcheck","redis-enterprise","multidb"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}