{"id":"8dc200161ce9349a","repo":"redis/redis-py","slug":"no-valid-database-available-for-communication-8dc200","errorCode":null,"errorMessage":"No valid database available for communication","messagePattern":"No valid database available for communication","errorType":"exception","errorClass":"NoValidDatabaseException","httpStatus":null,"severity":"error","filePath":"redis/multidb/failover.py","lineNumber":66,"sourceCode":"    def execute(self) -> SyncDatabase:\n        \"\"\"Execute the failover strategy.\"\"\"\n        pass\n\n\nclass WeightBasedFailoverStrategy(FailoverStrategy):\n    \"\"\"\n    Failover strategy based on database weights.\n    \"\"\"\n\n    def __init__(self) -> None:\n        self._databases = WeightedList()\n\n    def database(self) -> SyncDatabase:\n        for database, _ in self._databases:\n            if database.circuit.state == CBState.CLOSED:\n                return database\n\n        raise NoValidDatabaseException(\"No valid database available for communication\")\n\n    def set_databases(self, databases: Databases) -> None:\n        self._databases = databases\n\n\nclass DefaultFailoverStrategyExecutor(FailoverStrategyExecutor):\n    \"\"\"\n    Executes given failover strategy.\n    \"\"\"\n\n    def __init__(\n        self,\n        strategy: FailoverStrategy,\n        failover_attempts: int = DEFAULT_FAILOVER_ATTEMPTS,\n        failover_delay: float = DEFAULT_FAILOVER_DELAY,\n    ):\n        self._strategy = strategy\n        self._failover_attempts = failover_attempts","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/multidb/failover.py#L48-L84","documentation":"Error \"No valid database available for communication\" thrown in redis/redis-py.","triggerScenarios":"Thrown at redis/multidb/failover.py:66 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}