{"id":"f7857ef35e84c5a5","repo":"redis/redis-py","slug":"cluster-mode-is-not-enabled-on-this-node","errorCode":null,"errorMessage":"Cluster mode is not enabled on this node","messagePattern":"Cluster mode is not enabled on this node","errorType":"exception","errorClass":"RedisClusterException","httpStatus":null,"severity":"critical","filePath":"redis/asyncio/cluster.py","lineNumber":2281,"sourceCode":"            for startup_node in chain(\n                startup_nodes,\n                additional_startup_nodes,\n                deferred_failed_nodes,\n            ):\n                try:\n                    # Make sure cluster mode is enabled on this node\n                    try:\n                        self._event_dispatcher.dispatch(\n                            AfterAsyncClusterInstantiationEvent(\n                                self.nodes_cache,\n                                self.connection_kwargs.get(\"credential_provider\", None),\n                            )\n                        )\n                        cluster_slots = await startup_node.execute_command(\n                            \"CLUSTER SLOTS\"\n                        )\n                    except ResponseError:\n                        raise RedisClusterException(\n                            \"Cluster mode is not enabled on this node\"\n                        )\n                    startup_nodes_reachable = True\n                except Exception as e:\n                    # Try the next startup node.\n                    # The exception is saved and raised only if we have no more nodes.\n                    exception = e\n                    continue\n\n                # CLUSTER SLOTS command results in the following output:\n                # [[slot_section[from_slot,to_slot,master,replica1,...,replicaN]]]\n                # where each node contains the following list: [IP, port, node_id]\n                # Therefore, cluster_slots[0][2][0] will be the IP address of the\n                # primary node of the first slot section.\n                # If there's only one server in the cluster, its ``host`` is ''\n                # Fix it to the host in startup_nodes\n                if (\n                    len(cluster_slots) == 1","sourceCodeStart":2263,"sourceCodeEnd":2299,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/asyncio/cluster.py#L2263-L2299","documentation":"Raised during initialize() when a startup node's CLUSTER SLOTS call fails with a ResponseError. A ResponseError here (rather than a connection error) typically means the node answered but is not configured as a cluster node — e.g. it is a standalone Redis server without 'cluster-enabled yes'. The library wraps it as RedisClusterException and tries the next startup node, surfacing this message only if all candidates fail the same way.","triggerScenarios":"Pointing RedisCluster at a plain (non-cluster) Redis instance; a node whose cluster-enabled no; a proxy/middleware that rejects CLUSTER SLOTS; connecting to the wrong port that happens to serve a standalone Redis.","commonSituations":"Dev/stage misconfiguration: spinning up a single redis-server without cluster mode and connecting with RedisCluster; pointing at a sentinel or standalone instance by mistake; environment URL pointing at the wrong deployment.","solutions":["Verify the target is a real cluster: run redis-cli -h <host> -p <port> CLUSTER INFO and check cluster_enabled:1.","Start the server with cluster-enabled yes (and cluster-config-file, cluster-node-timeout) — or use a cluster-aware docker image.","If you actually want standalone Redis, use redis.asyncio.Redis instead of RedisCluster."],"exampleFix":"// before\nrc = RedisCluster(host='localhost', port=6379)  # plain redis-server\n\n// after\n# either use the standalone client\nr = redis.asyncio.Redis(host='localhost', port=6379)\n# or run the server with: redis-server --cluster-enabled yes --cluster-config-file nodes.conf --cluster-node-timeout 5000","handlingStrategy":"validation","validationCode":"import asyncio, socket\n\nasync def assert_cluster_node(host, port, password=None):\n    # Quick reachability + cluster check before constructing RedisCluster\n    try:\n        reader, writer = await asyncio.wait_for(\n            asyncio.open_connection(host, port), timeout=3)\n    except (OSError, asyncio.TimeoutError) as e:\n        raise RuntimeError(f'{host}:{port} unreachable: {e}')\n    writer.write(b'CLUSTER INFO\\r\\n')\n    await writer.drain()\n    resp = await reader.read(512)\n    writer.close()\n    if b'cluster_enabled:1' not in resp:\n        raise RuntimeError(f'{host}:{port} is not a cluster node')","typeGuard":"def is_cluster_endpoint(cluster_info_text: str) -> bool:\n    return 'cluster_enabled:1' in cluster_info_text and 'cluster_state:ok' in cluster_info_text","tryCatchPattern":"from redis.cluster import RedisClusterException\n\ntry:\n    rc = RedisCluster(host=h, port=p)\nexcept RedisClusterException as e:\n    if 'not enabled' in str(e):\n        # use standalone client instead\n        import redis.asyncio as redis\n        r = redis.Redis(host=h, port=p)\n    else:\n        raise","preventionTips":["Confirm CLUSTER INFO returns cluster_enabled:1 before pointing RedisCluster at a node.","Use redis.asyncio.Redis for non-cluster deployments.","Bake a connectivity/cluster-mode preflight check into deployment scripts."],"tags":["redis-cluster","startup","misconfiguration","non-cluster-node"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}