(error) OOM command not allowed when used memory > 'maxmemory'.
Writes are failing, reads still work, and the dashboard says Redis is at 100% memory. Here's what the error really means, how to fix it right now, and how to stop it happening again.
What's happening
Redis keeps everything in RAM. When maxmemory is set and used memory goes past it, Redis applies the eviction policy. The default policy is noeviction: don't delete anything, and reject every command that would use more memory. Reads, DEL and other shrinking commands still work. SET, LPUSH, HSET and friends fail.
So the error is Redis doing what it was configured to do. The question is whether this instance is a cache (safe to lose keys) or a datastore (it isn't).
Look before changing anything
redis-cli INFO memory
Key fields:
used_memory_humanvsmaxmemory_human: how full is it?maxmemory_policy: probablynoeviction.mem_fragmentation_ratio: well above 1.5 means RSS is much bigger than the data (fragmentation); below 1 means the OS is swapping Redis.
redis-cli INFO keyspace # keys per DB, and how many have a TTL ("expires=")
redis-cli --bigkeys # largest key of each type
redis-cli --memkeys # (Redis 7+) keys using the most memory
redis-cli MEMORY USAGE some:key
The most useful number is how many keys have no TTL. If keys=4000000,expires=12000, your "cache" is really a store that only grows.
The quick fix, if Redis is a cache
Let Redis evict:
redis-cli CONFIG SET maxmemory-policy allkeys-lru
Writes succeed immediately; Redis now removes the least recently used keys to make room. Persist it in redis.conf (or with CONFIG REWRITE) so it survives a restart.
Which policy to choose:
