{"record":{"id":"4657446abff99e1d","repo":"redis/redis-py","slug":"redis-cluster-cannot-be-connected-please-provide-465744","errorCode":null,"errorMessage":"Redis Cluster cannot be connected. Please provide at least one reachable node: {str(exception)}","messagePattern":"Redis Cluster cannot be connected\\. Please provide at least one reachable node: (.+?)","errorType":"exception","errorClass":"RedisClusterException","httpStatus":null,"severity":"critical","filePath":"redis/cluster.py","lineNumber":2774,"sourceCode":"                            if tmp_slot.name != target_node.name:\n                                disagreements.append(\n                                    f\"{tmp_slot.name} vs {target_node.name} on slot: {i}\"\n                                )\n\n                                if len(disagreements) > 5:\n                                    raise RedisClusterException(\n                                        f\"startup_nodes could not agree on a valid \"\n                                        f\"slots cache: {', '.join(disagreements)}\"\n                                    )\n\n                fully_covered = self.check_slots_coverage(tmp_slots)\n                if fully_covered:\n                    # Don't need to continue to the next startup node if all\n                    # slots are covered\n                    break\n\n            if not startup_nodes_reachable:\n                raise RedisClusterException(\n                    f\"Redis Cluster cannot be connected. Please provide at least \"\n                    f\"one reachable node: {str(exception)}\"\n                ) from exception\n\n            # Create Redis connections to all nodes\n            self.create_redis_connections(list(tmp_nodes_cache.values()))\n\n            # Check if the slots are not fully covered\n            if not fully_covered and self._require_full_coverage:\n                # Despite the requirement that the slots be covered, there\n                # isn't a full coverage\n                raise RedisClusterException(\n                    f\"All slots are not covered after query all startup_nodes. \"\n                    f\"{len(tmp_slots)} of {REDIS_CLUSTER_HASH_SLOTS} \"\n                    f\"covered...\"\n                )\n\n            # Set the tmp variables to the real variables","sourceCodeStart":2756,"sourceCodeEnd":2792,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/cluster.py#L2756-L2792","documentation":"Raised as a RedisClusterException when none of the provided startup_nodes could be reached during initial topology discovery. The loop at cluster.py:2653-2708 tries each startup node, catches all exceptions, and if startup_nodes_reachable is still False after exhausting the list, raises this with the last exception chained (cluster.py:2773-2777). The message includes the underlying exception for diagnosis.","triggerScenarios":"Constructing RedisCluster with a host/port (or startup_nodes) where every node is unreachable: wrong host, wrong port, network partition, firewall, or all nodes are down. The last caught exception is embedded in the message.","commonSituations":"Typo in host or port, Redis cluster containers not started, network/firewall blocking the port, TLS mismatch (connecting plain to a TLS port), or DNS resolution failure.","solutions":["Verify at least one node is reachable: telnet host port or redis-cli -h host -p ping.","Check the host and port values in the RedisCluster constructor for typos.","If using TLS, pass ssl=True and the correct ssl_* parameters, or remove them if not.","Ensure the Redis cluster containers/services are running (docker-compose ps, systemctl status redis)."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"import socket\ndef is_reachable(host: str, port: int, timeout=2) -> bool:\n    try:\n        with socket.create_connection((host, port), timeout=timeout):\n            return True\n    except OSError:\n        return False\n\n# Validate all startup nodes are reachable\nfor h, p in startup_nodes:\n    assert is_reachable(h, p), f'Cannot reach {h}:{p}'","typeGuard":"def startup_nodes_reachable(nodes: list) -> bool:\n    import socket\n    for h, p in nodes:\n        try:\n            with socket.create_connection((h, p), timeout=2):\n                pass\n        except OSError:\n            return False\n    return True","tryCatchPattern":"from redis.exceptions import RedisClusterException\ntry:\n    client = RedisCluster(host, port)\nexcept RedisClusterException as e:\n    if 'cannot be connected' in str(e):\n        # inspect underlying exception, fix network/config, then retry\n        raise","preventionTips":["Verify at least one startup node is reachable with redis-cli before constructing the client.","Double-check host and port values for typos.","Ensure firewall/network allows the Redis port, and TLS settings match."],"tags":["connection","initialization","network","cluster"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}