{"record":{"id":"857963c7f5d1c0fb","repo":"redis/redis-py","slug":"could-not-find-a-matching-bdb","errorCode":null,"errorMessage":"Could not find a matching bdb","messagePattern":"Could not find a matching bdb","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"redis/asyncio/multidb/healthcheck.py","lineNumber":499,"sourceCode":"        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\n                    break\n\n                # In case if the host was set as public IP\n                for addr in endpoint[\"addr\"]:\n                    if addr == db_host:\n                        matching_bdb = bdb\n                        break\n\n        if matching_bdb is None:\n            logger.warning(\"LagAwareHealthCheck failed: Couldn't find a matching bdb\")\n            raise ValueError(\"Could not find a matching bdb\")\n\n        url = (\n            f\"/v1/bdbs/{matching_bdb['uid']}/availability\"\n            f\"?extend_check=lag&availability_lag_tolerance_ms={self._lag_aware_tolerance}\"\n        )\n        await self._http_client.get(url, expect_json=False)\n\n        # Status checked in an http client, otherwise HttpError will be raised\n        return True\n","sourceCodeStart":481,"sourceCodeEnd":509,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/asyncio/multidb/healthcheck.py#L481-L509","documentation":"Raised as a ValueError in LagAwareHealthCheck.check_health after iterating all bdbs returned by the Redis Enterprise /v1/bdbs endpoint and finding none whose endpoint dns_name or addr matches the host the client is currently connected to. The health checker cannot correlate the live connection to a tracked database, so it cannot look up availability/lag. This usually indicates a mismatch between the connection target and what the REST API reports.","triggerScenarios":"check_health() runs, fetches /v1/bdbs, and every bdb's endpoint dns_name and addr list differ from the client's resolved host (db_host taken from client.get_connection_kwargs()['host'] for a standalone client or get_nodes()[0].host for a cluster client).","commonSituations":"Connecting via a public IP while the REST API only lists internal DNS names (the code checks both, but a NAT/different IP still misses). Using a load balancer or proxy host that does not appear in the bdb endpoint list. Stale REST API state after a database was recreated with a new uid/endpoints.","solutions":["Ensure the client connects to the exact host (DNS name or IP) listed in the bdb endpoints on the Redis Enterprise admin UI/API.","Refresh the /v1/bdbs listing and confirm the database still exists and its endpoint matches db_host.","If connecting through a proxy, add the proxy's host to the bdb endpoint addr list or connect directly."],"exampleFix":"# before\nclient = AsyncRedis(host=\"10.0.0.99\")  # not in any bdb endpoint\n# after\nclient = AsyncRedis(host=\"redis-12345.cluster.local\")  # matches bdb endpoint dns_name","handlingStrategy":"try-catch","validationCode":"host = database.client.get_connection_kwargs()[\"host\"]\nbdbs = await http_client.get(\"/v1/bdbs\")\nknown_hosts = {ep[\"dns_name\"] for b in bdbs for ep in b[\"endpoints\"]}\nknown_hosts |= {a for b in bdbs for ep in b[\"endpoints\"] for a in ep[\"addr\"]}\nif host not in known_hosts:\n    raise ValueError(f\"client host {host} not in any bdb endpoint\")","typeGuard":null,"tryCatchPattern":"try:\n    await lag_hc.check_health(database, client)\nexcept ValueError as e:\n    if \"matching bdb\" in str(e):\n        logger.warning(\"bdb match failed for host; check REST API endpoints\")\n    else:\n        raise","preventionTips":["Connect using the exact DNS name listed in the bdb endpoints.","Confirm the bdb list includes the client host before enabling lag-aware checks."],"tags":["multidb","health-check","redis-enterprise","network"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}