ERR value is not an integer or out of range

A command requires a whole number, but the stored value or an argument is not a whole number.

Redis returns this error when a command needs a whole number but gets something else. The problem can be an argument you passed, or the value stored in the key.

ERR value is not an integer or out of range

In client libraries

Client libraryException or error typeMessage
redis-py ResponseError value is not an integer or out of range
Jedis JedisDataException ERR value is not an integer or out of range
node-redis SimpleError ERR value is not an integer or out of range
Lettuce
The async API wraps the exception in an ExecutionException (get()) or a CompletionException (join()).
RedisCommandExecutionException ERR value is not an integer or out of range
go-redis redis.Error ERR value is not an integer or out of range
ioredis ReplyError ERR value is not an integer or out of range
StackExchange.Redis
NRedisStack uses StackExchange.Redis, so it raises the same exceptions. The sync and async APIs raise the same exceptions.
RedisServerException ERR value is not an integer or out of range
Predis Predis\Response\ServerException ERR value is not an integer or out of range
redis-rb Redis::CommandError ERR value is not an integer or out of range (redis://<host>:<port>)
redis-rs
The sync and async APIs raise the same errors.
ErrorKind::Server(ServerErrorKind::ResponseError) ResponseError: value is not an integer or out of range

Example

INCR adds 1 to the number stored in a key, so it fails when the key holds text:

> SET counter "abc"
OK
> INCR counter
(error) ERR value is not an integer or out of range

An argument that should be a number gives the same error:

> EXPIRE counter ten
(error) ERR value is not an integer or out of range

How to fix it

  • The key holds text or a decimal number. INCR, DECR, INCRBY, and DECRBY only work on whole numbers, such as 10 or -3. A value such as 1.5 gives this error too. To add to a decimal number, use INCRBYFLOAT.
  • An argument isn't a whole number. Arguments such as expiry times and counts must be whole numbers written as digits. Look for units or decimals, such as 10s or 2.5.
  • The number is too large. Redis stores these numbers as signed 64-bit integers, so the largest value is 9223372036854775807. When an increment would go past that, the error is ERR increment or decrement would overflow.

Commands that take decimal numbers, such as INCRBYFLOAT, give a similar error when the value isn't a number: ERR value is not a valid float.

RATE THIS PAGE
Back to top ↑
⌂ 换网址