redis/redis-py · error · RedisClusterException
Node : doesn't exist in the cluster
Error message
Node {host}:{port} doesn't exist in the cluster What it means
Raised as a RedisClusterException by _raise_on_invalid_node() (used by ClusterPubSub) when the provided node is None or is not found in the cluster's node cache (cluster.py:3036-3039). This means the host:port or ClusterNode passed to pubsub() does not correspond to any known node in the current topology.
Solutions
- Verify the node exists: client.get_node(host, port) returns a ClusterNode before passing it to pubsub().
- Use a known node from client.get_nodes() or client.get_primaries() instead of a hardcoded address.
- If using a ClusterNode object, ensure it came from the same client instance's topology.
Example fix
// before ps = client.pubsub(host='10.0.0.99', port=7000) # wrong address // after nodes = client.get_primaries() ps = client.pubsub(node=nodes[0])
Defensive patterns
Strategy: validation
Validate before calling
# Verify the node exists in the cluster before using it
node = client.get_node(host, port)
if node is None:
raise ValueError(f'Node {host}:{port} is not in the cluster')
ps = client.pubsub(node=node) Type guard
def node_exists_in_cluster(client, host, port) -> bool:
return client.get_node(host=host, port=port) is not None Try / catch
from redis.exceptions import RedisClusterException
try:
ps = client.pubsub(host=h, port=p)
except RedisClusterException as e:
if "doesn't exist in the cluster" in str(e):
ps = client.pubsub(node=client.get_primaries()[0]) Prevention
- Use client.get_node(host, port) to confirm a node exists before passing it to pubsub().
- Prefer passing ClusterNode objects from client.get_primaries()/get_nodes() over hardcoded addresses.
- Refresh topology before using stale addresses after cluster changes.
When it happens
Trigger: Calling client.pubsub(host=h, port=p) or client.pubsub(node=n) where h:p or n is not a member of the cluster (wrong address, typo, or a node that was removed). get_node() returns None or get_node(node_name=...) returns None.
Common situations: Using a stale host:port from before a cluster topology change, typo in address, or passing a ClusterNode from a different cluster instance.
Related errors
- Passing a host requires passing a port, and vice versa
- PubSub is not supported for RedisCluster
- Cluster client has no nodes - cannot create health check…
- Failed to subscribe to cluster nodes
- For "stable" state please use cluster_setslot_stable
AI-assisted analysis of redis/redis-py@6a6b581b48 (2026-08-10).
Data as JSON: /api/errors/da20cf7c0094bda5.
Report an issue: GitHub.
Appendix: source
Thrown at redis/cluster.py:3037
else:
# nothing passed by the user. set node to None
pubsub_node = None
self.node = pubsub_node
def get_pubsub_node(self):
"""
Get the node that is being used as the pubsub connection
"""
return self.node
def _raise_on_invalid_node(self, redis_cluster, node, host, port):
"""
Raise a RedisClusterException if the node is None or doesn't exist in
the cluster.
"""
if node is None or redis_cluster.get_node(node_name=node.name) is None:
raise RedisClusterException(
f"Node {host}:{port} doesn't exist in the cluster"
)
def execute_command(self, *args):
"""
Execute a subscribe/unsubscribe command.
Taken code from redis-py and tweak to make it work within a cluster.
"""
# NOTE: don't parse the response in this function -- it could pull a
# legitimate message off the stack if the connection is already
# subscribed to one or more channels
if self.connection is None:
if self.connection_pool is None:
if len(args) > 1:
# Hash the first channel and get one of the nodes holding
# this slotView on GitHub (pinned to 6a6b581b48)