// Redis error reference

OOM: Memory limit reached

The dataset reached the maxmemory limit and the eviction policy cannot free enough memory, so Redis refuses write commands.

Error prefix
OOM
Category
Memory and persistence
Error message
OOM command not allowed when used memory > 'maxmemory'.

What it means

OOM is the write-path refusal when used_memory is over maxmemory and the configured maxmemory-policy cannot free enough: noeviction evicts nothing by definition, and even an allkeys policy can fail when the incoming write is larger than what eviction can reclaim. Read commands keep working, and so do commands without the deny-oom flag, such as DEL; a SET is refused at the limit even when the new value is smaller.

The message names the two knobs precisely: the ceiling is maxmemory and the behavior at the ceiling is maxmemory-policy. Which one to change depends on what the data is: a cache wants an eviction policy; a system of record wants more memory or a smaller dataset.

Common causes

  • maxmemory is set and the working set grew past it, with the policy at its default of noeviction.
  • An allkeys or volatile policy still could not free enough for the incoming write.
  • A single very large value arrives at a moment when eviction has already freed everything it can.

Find the cause

INFO memory
# used_memory versus maxmemory, and the policy in force
INFO stats | grep evicted
# How often eviction already ran to make room
redis-cli --bigkeys
# Where the bytes are: the largest keys by type

maxmemory policies at the limit

noevictionThe default. Write commands are refused with OOM, including ones that would not grow memory; reads keep working.
allkeys-lru / allkeys-lfuEvicts the least recently or least frequently used key, across all keys, to fit the write.
volatile-*Evicts only keys with a TTL. When no key has one, it behaves like noeviction.
allkeys-random / volatile-randomEvicts a random key from the eligible set.

How to fix it

  1. See where you stand before changing anything:

    INFO memory
    # used_memory_human, maxmemory_human, maxmemory_policy
    CONFIG GET maxmemory
  2. For a cache, let Redis free space itself by switching the policy:

    CONFIG SET maxmemory-policy allkeys-lru
  3. For data that must not be evicted, raise the limit or shrink the dataset, then persist the change:

    CONFIG SET maxmemory 2gb
    CONFIG REWRITE

Other ways to handle it

Split by tier: keep evictable data such as sessions and caches in one instance with allkeys-lru, and durable data in another with noeviction plus alerts on used_memory. On the client, tolerate OOM for best-effort writes but never for ledger-style ones.

Reproduce it safely

redis-server --port 7306 --maxmemory 2mb --maxmemory-policy noeviction --save '' &
head -c 3000000 /dev/zero | tr '\0' 'a' | redis-cli -p 7306 -x SET big
# (error) OOM command not allowed when used memory > 'maxmemory'.

Questions

Why do reads still work when writes get OOM?

The limit guards memory growth. Reads are not flagged to be refused at the limit, so Redis serves them, while write commands flagged deny-oom are refused whether or not they grow the dataset.

What does maxmemory 0 mean?

No Redis-side limit: the process grows until the operating system stops it. The OOM refusal only applies when maxmemory is set to a byte value.

Related errors

More memory and persistence errors

The code and message text are from the Redis documentation and source code. Browse the full Redis error list or search every database error.

// fewer errors, faster fixes

Work on Redis in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for Redis and the other databases you use.

Text and data on this page: CC BY 4.0, credit SQLly (sqlly.app). Code and SQL snippets: MIT. License details Quoted error message text belongs to its database vendor. View as Markdown