{"record":{"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/6a6b581b48225afa0b76912d1028c6035baee932/redis/client.py#L1080-L1116","documentation":"Raised as RedisError in Monitor._start_monitor after sending the MONITOR command if the server response is not the OK status (bool_ok). MONITOR puts the connection into a special server-side mode that streams every command; if the server rejects it (e.g. ACL denial, or a non-standard reply), the response is included in the message for diagnosis. The Monitor object cannot function without entering monitor mode.","triggerScenarios":"Calling client.monitor() then next_command()/listen() (which lazily calls _start_monitor) against a server that does not reply OK to MONITOR. Commonly an ACL/permission denial (NOPERM), or an error reply from a proxy/managed Redis that disallows MONITOR.","commonSituations":"Connecting with a user that lacks the MONITOR privilege (ACL). Using a managed Redis (some Redis Cloud / proxy configs) where MONITOR is disabled. A server that returned an error string instead of OK.","solutions":["Grant the MONITOR permission to the user: `ACL SETUSER <user> on >password ~* +monitor`.","Use an admin-capable user for the monitor connection.","Check the {response} value in the error to see the exact server reply and act on it.","If MONITOR is disabled by your provider, use a different observability mechanism (SLOWLOG, etc.)."],"exampleFix":"# before: user lacks MONITOR permission\nmon = r.monitor()\n# server denies -> RedisError: MONITOR failed: ...\n# after: grant permission\n# redis-cli: ACL SETUSER appuser on >pass ~* +monitor\nmon = r.monitor()","handlingStrategy":"try-catch","validationCode":"info = await client.acl_getuser() if False else None  # placeholder\n# verify the user has +monitor via ACL GETUSER before calling monitor()","typeGuard":null,"tryCatchPattern":"from redis.exceptions import RedisError\ntry:\n    mon = client.monitor()\n    await mon.next_command()\nexcept RedisError as e:\n    if \"MONITOR failed\" in str(e):\n        logger.error(\"MONITOR denied: %s; check ACL +monitor permission\", e)\n    raise","preventionTips":["Grant the +monitor ACL permission to the monitoring user.","Inspect the server's MONITOR reply in the error to diagnose non-OK responses."],"tags":["monitor","acl","permissions","command"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}