{"record":{"id":"4a262becde1dd566","repo":"redis/redis-py","slug":"cmd-name-command-doesn-t-exist-in-redis-commands","errorCode":null,"errorMessage":"{cmd_name} command doesn't exist in Redis commands","messagePattern":"(.+?) command doesn't exist in Redis commands","errorType":"exception","errorClass":"RedisError","httpStatus":null,"severity":"error","filePath":"redis/_parsers/commands.py","lineNumber":150,"sourceCode":"        if len(args) < 2:\n            # The command has no keys in it\n            return None\n\n        cmd_name = args[0].lower()\n        if cmd_name not in self.commands:\n            # try to split the command name and to take only the main command,\n            # e.g. 'memory' for 'memory usage'\n            cmd_name_split = cmd_name.split()\n            cmd_name = cmd_name_split[0]\n            if cmd_name in self.commands:\n                # save the split command to args\n                args = cmd_name_split + list(args[1:])\n            else:\n                # We'll try to reinitialize the commands cache, if the engine\n                # version has changed, the commands may not be current\n                self.initialize(redis_conn)\n                if cmd_name not in self.commands:\n                    raise RedisError(\n                        f\"{cmd_name.upper()} command doesn't exist in Redis commands\"\n                    )\n\n        command = self.commands.get(cmd_name)\n        if \"movablekeys\" in command[\"flags\"]:\n            keys = self._get_moveable_keys(redis_conn, *args)\n        elif \"pubsub\" in command[\"flags\"] or command[\"name\"] == \"pubsub\":\n            keys = self._get_pubsub_keys(*args)\n        else:\n            if (\n                command[\"step_count\"] == 0\n                and command[\"first_key_pos\"] == 0\n                and command[\"last_key_pos\"] == 0\n            ):\n                is_subcmd = False\n                if \"subcommands\" in command:\n                    subcmd_name = f\"{cmd_name}|{args[1].lower()}\"\n                    for subcmd in command[\"subcommands\"]:","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/_parsers/commands.py#L132-L168","documentation":"Raised by the sync CommandsParser.get_keys() (redis/_parsers/commands.py:150) when a command name is not found in the cached COMMAND output even after a fresh re-initialization (self.initialize()). The cluster client calls get_keys() to learn which slots to route keys to; if the server does not know the command, key positions cannot be determined. It is raised as RedisError(\"<CMD> command doesn't exist in Redis commands\").","triggerScenarios":"Running a command in Redis Cluster whose name isn't registered with the server: a typo, a custom/module command whose module isn't loaded, or a command renamed via rename-command. get_keys() splits the name (e.g. 'memory usage' -> 'memory'), re-queries COMMAND, and still fails.","commonSituations":"Typos like r.execute_command('ST'); calling a module command (e.g. JSON.GET) without the module loaded; rename-command in redis.conf; cluster nodes running different Redis versions so COMMAND output differs; very old server missing a newer command.","solutions":["Verify the exact command name/casing against the server with redis-cli COMMAND INFO <name>.","Ensure any module providing the command is loaded (MODULE LIST) on every cluster node.","For custom/module commands, use the dedicated module API rather than routing through cluster get_keys.","Align Redis versions across cluster nodes so COMMAND output is consistent."],"exampleFix":"# before\nawait r.execute_command(\"ST\", \"key\", \"val\")  # typo -> 'ST command doesn't exist'\n\n# after\nawait r.execute_command(\"SET\", \"key\", \"val\")","handlingStrategy":"validation","validationCode":"# Validate a command exists in the server's COMMAND cache before routing\nknown = r.execute_command(\"COMMAND\")  # dict of command names\nname = \"MYCMD\"\nif name.lower() not in {k.lower() for k in known}:\n    raise ValueError(f\"{name} is not a registered Redis command\")","typeGuard":null,"tryCatchPattern":"try:\n    r.execute_command(\"MYCMD\", \"key\")\nexcept redis.RedisError as e:\n    if \"command doesn't exist in Redis commands\" in str(e):\n        # typo / module not loaded / rename-command\n        ...","preventionTips":["Confirm commands with redis-cli COMMAND INFO <name>.","Load required modules on every cluster node.","Use the dedicated module command APIs instead of routing custom commands through cluster get_keys."],"tags":["cluster","commands","redis-server","routing"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}