redis/redis-py · error · ConnectionError
READONLY command failed
Error message
READONLY command failed
What it means
Error "READONLY command failed" thrown in redis/redis-py.
Source
Thrown at redis/cluster.py:1026
# Client was already disconnected. do nothing
pass
def on_connect(self, connection):
"""
Initialize the connection, authenticate and select a database and send
READONLY if it is set during object initialization.
"""
connection.on_connect()
if self.read_from_replicas or self.load_balancing_strategy:
# Sending READONLY command to server to configure connection as
# readonly. Since each cluster node may change its server type due
# to a failover, we should establish a READONLY connection
# regardless of the server type. If this is a primary connection,
# READONLY would not affect executing write commands.
connection.send_command("READONLY")
if str_if_bytes(connection.read_response()) != "OK":
raise ConnectionError("READONLY command failed")
if self.user_on_connect_func is not None:
self.user_on_connect_func(connection)
def get_redis_connection(self, node: "ClusterNode") -> Redis:
if not node.redis_connection:
with self._lock:
if not node.redis_connection:
self.nodes_manager.create_redis_connections([node])
return node.redis_connection
def get_node(self, host=None, port=None, node_name=None):
return self.nodes_manager.get_node(host, port, node_name)
def get_primaries(self):
return self.nodes_manager.get_nodes_by_server_type(PRIMARY)
def get_replicas(self):View on GitHub (pinned to da03cdc7e8)
When it happens
Trigger: Thrown at redis/cluster.py:1026 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of redis/redis-py@da03cdc7e8 (2026-08-04).
Data as JSON: /data/errors/313e23c2a41db5bc.json.
Report an issue: GitHub.