{"id":"69e98d615da30e90","repo":"redis/redis-py","slug":"slaveof-is-not-supported-in-cluster-mode","errorCode":null,"errorMessage":"SLAVEOF is not supported in cluster mode","messagePattern":"SLAVEOF is not supported in cluster mode","errorType":"exception","errorClass":"RedisClusterException","httpStatus":null,"severity":"error","filePath":"redis/commands/cluster.py","lineNumber":458,"sourceCode":"        ]\n        return await pipe.execute()\n\n\nclass ClusterManagementCommands(ManagementCommands):\n    \"\"\"\n    A class for Redis Cluster management commands\n\n    The class inherits from Redis's core ManagementCommands class and do the\n    required adjustments to work with cluster mode\n    \"\"\"\n\n    def slaveof(self, *args, **kwargs) -> NoReturn:\n        \"\"\"\n        Make the server a replica of another instance, or promote it as master.\n\n        For more information see https://redis.io/commands/slaveof\n        \"\"\"\n        raise RedisClusterException(\"SLAVEOF is not supported in cluster mode\")\n\n    def replicaof(self, *args, **kwargs) -> NoReturn:\n        \"\"\"\n        Make the server a replica of another instance, or promote it as master.\n\n        For more information see https://redis.io/commands/replicaof\n        \"\"\"\n        raise RedisClusterException(\"REPLICAOF is not supported in cluster mode\")\n\n    def swapdb(self, *args, **kwargs) -> NoReturn:\n        \"\"\"\n        Swaps two Redis databases.\n\n        For more information see https://redis.io/commands/swapdb\n        \"\"\"\n        raise RedisClusterException(\"SWAPDB is not supported in cluster mode\")\n\n    @overload","sourceCodeStart":440,"sourceCodeEnd":476,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/commands/cluster.py#L440-L476","documentation":"RedisClusterCommands.slaveof (redis/commands/cluster.py:452) unconditionally raises RedisClusterException. SLAVEOF reconfigures a single standalone Redis instance's replication role; in cluster mode replication is managed per-node via the cluster topology, so the command is disabled on the cluster client surface.","triggerScenarios":"Calling rc.slaveof(...) (or rc.slaveof('NO','ONE')) on a RedisCluster client. Any code path, including legacy cutover scripts, that invokes SLAVEOF against a cluster endpoint.","commonSituations":"Migrating failover/replication scripts from standalone redis to cluster. Old runbooks that promoted/demoted nodes with SLAVEOF. Confusing SLAVEOF (deprecated alias) with CLUSTER FAILOVER.","solutions":["Use the cluster-native failover command: rc.cluster_failover(target_node=<replica>, option='FORCE' or 'TAKEOVER').","To change replication topology, use CLUSTER SETSLOT / redis-cli cluster management, not SLAVEOF.","Run SLAVEOF against a non-cluster client connected to the specific node if you truly need standalone behavior on a node that is not part of the cluster."],"exampleFix":"# before\nrc.slaveof('otherhost', 6379)  # raises: SLAVEOF is not supported in cluster mode\n\n# after\nrc.cluster_failover(target_node=replica_node, option='FORCE')","handlingStrategy":"type-guard","validationCode":"from redis.cluster import RedisCluster\n\ndef safe_replica_op(client, host=None, port=None):\n    if isinstance(client, RedisCluster):\n        raise ValueError('SLAVEOF is unsupported in cluster mode; use cluster_failover()')\n    return client.slaveof(host, port)","typeGuard":"from redis.cluster import RedisCluster\n\ndef is_cluster_client(client) -> bool:\n    return isinstance(client, RedisCluster)","tryCatchPattern":"from redis.exceptions import RedisClusterException\n\ntry:\n    rc.slaveof('NO', 'ONE')\nexcept RedisClusterException:\n    rc.cluster_failover(target_node=replica, option='FORCE')","preventionTips":["Use CLUSTER FAILOVER for cluster replication/failover control.","Detect cluster vs standalone clients in shared replication code.","Remove SLAVEOF from runbooks pointed at cluster endpoints."],"tags":["cluster","unsupported-command","replication"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}