{"id":"a97db608a55d5a13","repo":"redis/redis-py","slug":"monitor-failed-response-a97db6","errorCode":null,"errorMessage":"MONITOR failed: {response}","messagePattern":"MONITOR failed: (.+?)","errorType":"exception","errorClass":"RedisError","httpStatus":null,"severity":"error","filePath":"redis/client.py","lineNumber":1098,"sourceCode":"            \"db\": int(db_id),\n            \"client_address\": client_address,\n            \"client_port\": client_port,\n            \"client_type\": client_type,\n            \"command\": command,\n        }\n\n    def listen(self):\n        \"\"\"Listen for commands coming to the server.\"\"\"\n        while True:\n            yield self.next_command()\n\n    def _start_monitor(self):\n        self.connection.send_command(\"MONITOR\")\n        # check that monitor returns 'OK', but don't return it to user\n        response = self.connection.read_response()\n\n        if not bool_ok(response):\n            raise RedisError(f\"MONITOR failed: {response}\")\n\n\nclass PubSub:\n    \"\"\"\n    PubSub provides publish, subscribe and listen support to Redis channels.\n\n    After subscribing to one or more channels, the listen() method will block\n    until a message arrives on one of the subscribed channels. That message\n    will be returned and it's safe to start listening again.\n    \"\"\"\n\n    PUBLISH_MESSAGE_TYPES = (\"message\", \"pmessage\", \"smessage\")\n    UNSUBSCRIBE_MESSAGE_TYPES = (\"unsubscribe\", \"punsubscribe\", \"sunsubscribe\")\n    HEALTH_CHECK_MESSAGE = \"redis-py-health-check\"\n\n    def __init__(\n        self,\n        connection_pool,","sourceCodeStart":1080,"sourceCodeEnd":1116,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/client.py#L1080-L1116","documentation":"Raised in `_start_monitor` after the client sends MONITOR and reads the server reply: if the reply is not the Redis \"OK\" status (bool_ok fails), the server rejected or did not acknowledge the MONITOR command. The library throws RedisError because MONITOR is a special server-side mode that must be explicitly acknowledged before the client can begin reading the streamed command stream via `listen()`/`next_command()`.","triggerScenarios":"Calling `client.monitor()` (or directly instantiating the Monitor thread) against a Redis server that refuses MONITOR. This happens when the authenticated user lacks the monitoring ACL permission, when the server is a read-only replica configured to deny MONITOR, or when the connection received a non-OK framed reply (e.g. an error string or an authorization denial). The reply content is interpolated into the message for diagnostics.","commonSituations":"Using an ACL-restricted user without `+@admin`/monitoring rights; pointing the client at a proxy or managed Redis (Redis Cloud, AWS ElastiCache) that disables MONITOR; running MONITOR against a Sentinel or cluster node in a topology where the command is forbidden; corrupted protocol state causing a non-status reply.","solutions":["Grant the connecting user the necessary ACL permissions (e.g. `ACL SETUSER <user> on +@all -@dangerous ~*` or explicitly allow MONITOR) or connect with a user that has admin rights.","Verify the target is a standalone Redis that permits MONITOR; proxies/managed offerings may reject it — use a self-managed Redis or the provider's approved diagnostics instead.","Inspect the embedded `{response}` value to see the server's exact refusal reason and resolve that underlying error (AUTH, ACL, BUSYLOAD, etc.).","If the server only intermittently rejects MONITOR, retry after confirming server health and that no other session is already in a state that blocks it."],"exampleFix":"# before\nclient = redis.Redis(username='app', password='secret')\nm = client.monitor()  # raises: MONITOR failed: NOPERM ...\n\n# after (grant monitoring permission to the user)\n# ACL SETUSER app resetkeys on +@all ~*\nclient = redis.Redis(username='app', password='secret')\nm = client.monitor()","handlingStrategy":"try-catch","validationCode":"from redis.exceptions import RedisError\n# Before calling monitor(), confirm the server is reachable and the user likely has permission\ntry:\n    client.ping()\nexcept RedisError:\n    raise","typeGuard":null,"tryCatchPattern":"from redis.exceptions import RedisError\ntry:\n    mon = client.monitor()\n    for cmd in mon.listen():\n        ...\nexcept RedisError as e:\n    if 'MONITOR failed' in str(e):\n        # server rejected MONITOR — check ACL/server type\n        log.warning('monitor unavailable: %s', e)\n    else:\n        raise","preventionTips":["Use an ACL user with admin/monitoring rights for monitor-only tooling.","Confirm the target is a standalone Redis that permits MONITOR (not a managed proxy that blocks it)."],"tags":["redis-server","monitor","acl","permissions"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}