How to fix ERR wrong number of arguments in Redis

RedisINTERMEDIATEMEDIUMUpdated Dec 28, 2025· 240 views

This error occurs when a Redis command receives an incorrect number of arguments. Each Redis command has specific argument requirements, and supplying too few or too many arguments triggers this validation error.

Quick fix

Fixes ERR wrong number of arguments

help <commandname>
  1. Identify which command is failing
  2. Check the command documentation
  3. Count your arguments carefully
  4. Fix your command syntax
redis — error
help <commandname>
ERR wrong number of arguments

What this error means

Redis enforces strict argument validation for all commands. Every command has a defined arity—the exact number or minimum number of arguments it expects. When your command doesn't match these requirements, Redis rejects it with 'ERR wrong number of arguments' and includes the command name in the error message (e.g., 'ERR wrong number of arguments for set command'). This is a syntax error that prevents the command from executing at all.

Typical symptoms

  • Redis commands fail immediately with error message naming the specific command
  • Transactions halt at EXEC phase when a command has wrong argument count
  • Client libraries may wrap the error or display it differently depending on language
  • Scripts using redis-cli fail or hang waiting for response

Common causes

  1. Forgetting required arguments (e.g., SET key without value)
  2. Providing too many arguments for a command that expects a fixed count
  3. Unintended quotes or escape characters changing argument count
  4. Using old client library versions with incompatible syntax
  5. Misunderstanding command arity in transactions or pipelined commands

How to fix "ERR wrong number of arguments"

1Identify which command is failing

Look at your error message—it should specify the command name. For example, 'ERR wrong number of arguments for set command' tells you it's the SET command.

2Check the command documentation

Use redis-cli to look up the correct syntax. You can use:

bash
help <commandname>

For example, help set will show the exact format and required vs optional arguments.

Or use the COMMAND INFO subcommand:

bash
COMMAND INFO set
3Count your arguments carefully

Remember that in Redis command syntax:
- GET requires exactly 1 argument: GET key
- MGET accepts multiple arguments: MGET key1 [key2] [key3]...
- SET requires at least 2 arguments: SET key value [EX|PX|EXAT|PXAT] [NX|XX]

Note: Command arity counts include the command name itself in the specification.

4Fix your command syntax

Adjust your command to match the documented format. Common fixes:

Missing value in SET:

bash
// Wrong
SET mykey

// Correct
SET mykey myvalue

Extra arguments in GET:

bash
// Wrong
GET mykey extra_arg

// Correct
GET mykey

Wrong HSET format (if using older Redis):

bash
// Redis 3.0.0+ (multiple field-value pairs)
HSET myhash field1 value1 field2 value2

// Redis < 3.0.0 (one field-value pair only)
HSET myhash field1 value1
5Verify your client library version

If you're using a Redis client library (node-redis, redis-py, Predis, etc.), ensure it's up-to-date. Older versions may have different argument handling:

bash
# Node.js
npm list redis

# Python
pip show redis

Upgrade if you're on a very old version, as newer versions handle commands more correctly.

6Test in redis-cli first

If you're using a client library, test your exact command syntax in redis-cli first to isolate the issue:

bash
redis-cli
127.0.0.1:6379> SET mykey myvalue
OK
127.0.0.1:6379> GET mykey
"myvalue"

Once it works in redis-cli, the syntax is correct and the issue is likely in how you're passing arguments from your code.

Advanced notes

Command arity is defined as: positive integer = fixed number of arguments required; negative integer = minimum number of arguments. For example, GET has arity 2 (command + key), MGET has arity -2 (command + at least one key). During MULTI/EXEC transactions, syntax errors like wrong argument count are caught during MULTI phase and cause the entire transaction to be aborted—the bad command is never queued. In Lua scripts, incorrect argument counts trigger the same error when EVALSHA or EVAL are called with mismatched scripts and arguments.

Frequently asked questions

What does "ERR wrong number of arguments" mean?
Redis enforces strict argument validation for all commands. Every command has a defined arity—the exact number or minimum number of arguments it expects. , 'ERR wrong number of arguments for set command').
How do I fix "ERR wrong number of arguments"?
This error occurs when a Redis command receives an incorrect number of arguments. Each Redis command has specific argument requirements, and supplying too few or too many arguments triggers this validation error.
What causes "ERR wrong number of arguments"?
Forgetting required arguments (e.g., SET key without value) Providing too many arguments for a command that expects a fixed count Unintended quotes or escape characters changing argument count
Is the "ERR wrong number of arguments" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading