What the message looks like
OOM command not allowed when used memory > 'maxmemory'.Common causes
maxmemory-policy noevictionis active, which is the default. Redis evicts nothing and refuses writes instead.- Keys without a TTL fill memory, for example cache entries that never expire.
- A single large key grows without bound: a list, hash or set used as a queue.
- Fragmentation and replication buffers push
used_memoryabove the limit even though the data is smaller. - After a restart
maxmemoryis missing from the config, so Redis grows until the host runs out of memory.
Check
- Memory, limit and policy
redis-cli INFO memory | grep -E 'used_memory_human|maxmemory_human|maxmemory_policy' - Find the largest keys
redis-cli --bigkeys - Count evicted keys
redis-cli INFO stats | grep evicted_keys - Share of keys without TTL in a sample
redis-cli --scan --count 1000 | head -n 1000 | while read k; do redis-cli TTL "$k"; done | grep -c '^-1$'
Fix
- Choose the policy on purpose: for a pure cache use
allkeys-lruorallkeys-lfu, then Redis makes room itself. - Keep
noevictiononly if Redis holds data that must not be lost. Then add memory and set TTLs. - Set a TTL on every cache key, even the ones that look permanent.
- Split or cap large keys;
--bigkeysshows the candidates. - Keep
maxmemorywell below host RAM so snapshots and copy-on-write have room.
FAQ
Why does Redis not just drop old keys?
Because maxmemory-policy is noeviction, which is the default.
Do I lose data when I switch to allkeys-lru?
Yes, old keys get evicted. That is fine for a cache, not for queue or session data.