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.
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.
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.
Use redis-cli to look up the correct syntax. You can use:
help <commandname>For example, help set will show the exact format and required vs optional arguments.
Or use the COMMAND INFO subcommand:
COMMAND INFO setRemember 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.
Adjust your command to match the documented format. Common fixes:
Missing value in SET:
// Wrong
SET mykey
// Correct
SET mykey myvalueExtra arguments in GET:
// Wrong
GET mykey extra_arg
// Correct
GET mykeyWrong HSET format (if using older Redis):
// 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 value1If 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:
# Node.js
npm list redis
# Python
pip show redisUpgrade if you're on a very old version, as newer versions handle commands more correctly.
If you're using a client library, test your exact command syntax in redis-cli first to isolate the issue:
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.
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.
ERR Unbalanced XREAD list of streams
How to fix "ERR Unbalanced XREAD list" in Redis
ERR syntax error
How to fix "ERR syntax error" in Redis
ConnectionError: Error while reading from socket
ConnectionError: Error while reading from socket in redis-py
ERR unknown command
How to fix ERR unknown command in Redis
Command timed out
How to fix 'Command timed out' in ioredis