ERR syntax error
A command's options are misspelled, in the wrong place, or can't be used together.
Redis returns this error when it can't make sense of a command's options. The command name is right, but the options don't follow the command's syntax.
ERR syntax error
In client libraries
| Client library | Exception or error type | Message |
|---|---|---|
| redis-py | ResponseError |
syntax error |
| Jedis | JedisDataException |
ERR syntax error |
| node-redis | SimpleError |
ERR syntax error |
| Lettuce The async API wraps the exception in an ExecutionException (get()) or a CompletionException (join()). |
RedisCommandExecutionException |
ERR syntax error |
| go-redis | redis.Error |
ERR syntax error |
| ioredis | ReplyError |
ERR syntax error |
| StackExchange.Redis NRedisStack uses StackExchange.Redis, so it raises the same exceptions. The sync and async APIs raise the same exceptions. |
RedisServerException |
ERR syntax error |
| Predis | Predis\Response\ServerException |
ERR syntax error |
| redis-rb | Redis::CommandError |
ERR syntax error (redis://<host>:<port>) |
| redis-rs The sync and async APIs raise the same errors. |
ErrorKind::Server(ServerErrorKind::ResponseError) |
ResponseError: syntax error |
Example
The NX and XX options of SET can't be used together:
> SET mykey "value" NX XX
(error) ERR syntax error
How to fix it
The message doesn't say which option is wrong. Compare each option with the syntax on the command's page, and look for these common mistakes:
- Options that can't be used together, such as
NXandXXinSET. - A misspelled option, or one your server doesn't support yet. The history section of each command page lists the version that added each option.
- An option in the wrong place. For example, in
ZADD, options such asNXgo before the score and member.ZADD myset NX 1 "a"works, butZADD myset 1 "a" NXgives this error. - A value with spaces that isn't quoted. In
redis-cli,SET greeting hello worldsendsworldas an extra option. Put quotes around the value:SET greeting "hello world".