redis/redis-py · error · RedisClusterException
Cluster Node has no redis_connection
Error message
Cluster Node {target_node.name} has no redis_connection What it means
Raised as a RedisClusterException by the monitor() method when the target ClusterNode's redis_connection attribute is None, meaning no live Redis connection object has been created for that node. The monitor() method needs a raw connection to stream MONITOR output, so a missing connection is a hard failure.
Solutions
- Call client.get_redis_connection(target_node) first to force lazy connection creation before calling monitor().
- If no target_node is passed, let the client pick the default node (pass target_node=None).
- Verify the node is still part of the cluster topology with client.get_node(host, port) before using it.
Example fix
// before m = client.monitor(target_node=some_node) // after client.get_redis_connection(some_node) m = client.monitor(target_node=some_node)
Defensive patterns
Strategy: validation
Validate before calling
# Force connection before calling monitor()
if target_node and target_node.redis_connection is None:
client.get_redis_connection(target_node) Type guard
def node_has_connection(node) -> bool:
return node.redis_connection is not None Try / catch
from redis.exceptions import RedisClusterException
try:
m = client.monitor(target_node=node)
except RedisClusterException as e:
if 'has no redis_connection' in str(e):
client.get_redis_connection(node)
m = client.monitor(target_node=node) Prevention
- Call client.get_redis_connection(node) to lazily open a connection before monitor().
- Let the client pick the default node by omitting target_node.
- Verify the node is still in the cluster before using it.
When it happens
Trigger: Calling client.monitor(target_node=some_node) where some_node is a ClusterNode whose redis_connection was never initialized (e.g., a node discovered during topology mapping but never connected to). The check is at cluster.py:1184-1187.
Common situations: Passing a node obtained from get_nodes() or a slot-cache lookup whose lazy connection was never opened, or a node that has been removed from the cluster but still referenced by the application.
Related errors
- Failed to subscribe to cluster nodes
- Invalid Database
- READONLY command failed
- READONLY command failed
- Redis Cluster cannot be connected. Please provide at least…
AI-assisted analysis of redis/redis-py@6a6b581b48 (2026-08-10).
Data as JSON: /api/errors/ce0bf8684592e3e5.
Report an issue: GitHub.
Appendix: source
Thrown at redis/cluster.py:1185
self.nodes_manager.default_node = node
return True
def set_retry(self, retry: Retry) -> None:
self.retry = retry
def monitor(self, target_node=None):
"""
Returns a Monitor object for the specified target node.
The default cluster node will be selected if no target node was
specified.
Monitor is useful for handling the MONITOR command to the redis server.
next_command() method returns one command from monitor
listen() method yields commands from monitor.
"""
if target_node is None:
target_node = self.get_default_node()
if target_node.redis_connection is None:
raise RedisClusterException(
f"Cluster Node {target_node.name} has no redis_connection"
)
return target_node.redis_connection.monitor()
def pubsub(self, node=None, host=None, port=None, **kwargs):
"""
Allows passing a ClusterNode, or host&port, to get a pubsub instance
connected to the specified node
"""
return ClusterPubSub(self, node=node, host=host, port=port, **kwargs)
def keyspace_notifications(
self,
key_prefix: Union[str, bytes, None] = None,
ignore_subscribe_messages: bool = True,
) -> "ClusterKeyspaceNotifications":
"""
Return a :class:`~redis.keyspace_notifications.ClusterKeyspaceNotifications`View on GitHub (pinned to 6a6b581b48)