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.
Typical scenario
Laravel uses Redis for sessions and queues, maxmemory is set to 256 MB with the noeviction policy. One day logins fail because writing the session is refused with OOM command not allowed when used memory > 'maxmemory', while reads keep working. First clarify whether memory is filled with real data or with keys that have no expiry, before anyone raises the limit.
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.
Which eviction policy suits which use?
For pure caches allkeys-lru fits, since losing old entries is harmless. For data that must not vanish, such as queues or sessions, noeviction remains right. Then you have to plan memory or limit key growth, for example through expiry times.
How do I find the keys eating memory?
redis-cli --bigkeys gives an overview of the biggest keys per type, MEMORY USAGE key the consumption of a single one. For suspicious ones check with TTL key whether they expire at all. Missing expiry is the most common cause of creeping growth.
Why is the process memory above maxmemory?
maxmemory limits the payload data. The process additionally uses memory for fragmentation, buffers and while writing a snapshot. Plan headroom, and do not set maxmemory to the entire available RAM of the host.