ERR
RedisERRORNotableType ErrorHIGH confidence

Value is not an integer or out of range

Production Risk

Low. The server correctly rejects an invalid operation.

What this means

This error occurs when a command that expects an integer argument (like INCR or BITPOS) is used on a key that contains a non-integer string, or the operation would result in a value outside the 64-bit signed integer range.

Why it happens
  1. 1Attempting to `INCR` a key that holds a string like 'hello' or a floating-point number.
  2. 2The value stored in the key is already at the maximum value for a 64-bit signed integer.
  3. 3Providing a non-integer value as an argument to a command expecting one (e.g. `EXPIRE key 'onetwothree'`).
How to reproduce

A client tries to increment a key that holds a floating point number.

trigger — this will error
trigger — this will error
SET mykey "10.5"
INCR mykey

expected output

(error) ERR value is not an integer or out of range

Fix 1

Ensure the key holds an integer value

WHEN Before using integer-specific commands

Ensure the key holds an integer value
# Application logic should ensure only integers are set
SET mycounter 10
INCR mycounter

Why this works

By only storing valid, base-10 integer strings in keys intended for integer operations, you prevent this error.

Fix 2

Use `INCRBYFLOAT` for floating-point arithmetic

WHEN You need to work with decimal values

Use `INCRBYFLOAT` for floating-point arithmetic
SET mykey "10.5"
INCRBYFLOAT mykey 0.5

Why this works

Redis provides a separate set of commands for floating-point numbers. These commands correctly handle decimal values.

What not to do

Store numbers as floats when you only need integers

Using floating point numbers when not necessary can introduce precision issues and makes you unable to use atomic integer operations like `INCR`.

Sources
Official documentation ↗

String value to integer conversion logic

INCRBYFLOAT command

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All Redis errors