redis/redis-py · critical · RedisClusterException

Cluster mode is not enabled on this node

Error message

Cluster mode is not enabled on this node

What it means

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.

Source

Thrown at redis/asyncio/cluster.py:2281

            for startup_node in chain(
                startup_nodes,
                additional_startup_nodes,
                deferred_failed_nodes,
            ):
                try:
                    # Make sure cluster mode is enabled on this node
                    try:
                        self._event_dispatcher.dispatch(
                            AfterAsyncClusterInstantiationEvent(
                                self.nodes_cache,
                                self.connection_kwargs.get("credential_provider", None),
                            )
                        )
                        cluster_slots = await startup_node.execute_command(
                            "CLUSTER SLOTS"
                        )
                    except ResponseError:
                        raise RedisClusterException(
                            "Cluster mode is not enabled on this node"
                        )
                    startup_nodes_reachable = True
                except Exception as e:
                    # Try the next startup node.
                    # The exception is saved and raised only if we have no more nodes.
                    exception = e
                    continue

                # CLUSTER SLOTS command results in the following output:
                # [[slot_section[from_slot,to_slot,master,replica1,...,replicaN]]]
                # where each node contains the following list: [IP, port, node_id]
                # Therefore, cluster_slots[0][2][0] will be the IP address of the
                # primary node of the first slot section.
                # If there's only one server in the cluster, its ``host`` is ''
                # Fix it to the host in startup_nodes
                if (
                    len(cluster_slots) == 1

View on GitHub (pinned to da03cdc7e8)

Solutions

  1. Verify the target is a real cluster: run redis-cli -h <host> -p <port> CLUSTER INFO and check cluster_enabled:1.
  2. Start the server with cluster-enabled yes (and cluster-config-file, cluster-node-timeout) — or use a cluster-aware docker image.
  3. If you actually want standalone Redis, use redis.asyncio.Redis instead of RedisCluster.

Example fix

// before
rc = RedisCluster(host='localhost', port=6379)  # plain redis-server

// after
# either use the standalone client
r = redis.asyncio.Redis(host='localhost', port=6379)
# or run the server with: redis-server --cluster-enabled yes --cluster-config-file nodes.conf --cluster-node-timeout 5000
Defensive patterns

Strategy: validation

Validate before calling

import asyncio, socket

async def assert_cluster_node(host, port, password=None):
    # Quick reachability + cluster check before constructing RedisCluster
    try:
        reader, writer = await asyncio.wait_for(
            asyncio.open_connection(host, port), timeout=3)
    except (OSError, asyncio.TimeoutError) as e:
        raise RuntimeError(f'{host}:{port} unreachable: {e}')
    writer.write(b'CLUSTER INFO\r\n')
    await writer.drain()
    resp = await reader.read(512)
    writer.close()
    if b'cluster_enabled:1' not in resp:
        raise RuntimeError(f'{host}:{port} is not a cluster node')

Type guard

def is_cluster_endpoint(cluster_info_text: str) -> bool:
    return 'cluster_enabled:1' in cluster_info_text and 'cluster_state:ok' in cluster_info_text

Try / catch

from redis.cluster import RedisClusterException

try:
    rc = RedisCluster(host=h, port=p)
except RedisClusterException as e:
    if 'not enabled' in str(e):
        # use standalone client instead
        import redis.asyncio as redis
        r = redis.Redis(host=h, port=p)
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of redis/redis-py@da03cdc7e8 (2026-08-04). Data as JSON: /data/errors/f7857ef35e84c5a5.json. Report an issue: GitHub.