database
resource_error
ai_generated
true
redis.exceptions.ResponseError: OOM command not allowed when used memory > 'maxmemory'.
ID: database/redis-oom
90%Fix Rate
92%Confidence
60Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 7 | active | — | — | — |
Root Cause
Redis has reached its maxmemory limit and the configured eviction policy does not allow freeing memory for the current command. Write commands are rejected. Caused by storing too much data without an eviction policy, memory leaks from accumulating keys, or maxmemory set too low.
genericWorkarounds
-
92% success Configure an appropriate maxmemory-policy eviction strategy
Set an eviction policy: redis-cli CONFIG SET maxmemory-policy allkeys-lru (for cache use cases) or volatile-lru (to only evict keys with TTL). Make persistent in redis.conf. Choose the policy based on your use case: allkeys-lru for caches, volatile-ttl for session stores.
-
88% success Identify and remove large or unnecessary keys to free memory
Run: redis-cli --bigkeys to find the largest keys. Use redis-cli MEMORY USAGE <key> to check specific keys. Delete unnecessary keys with DEL or UNLINK (async). Set TTL on keys that should expire: EXPIRE key seconds. Monitor memory: redis-cli INFO memory.
Dead Ends
Common approaches that don't work:
-
Setting maxmemory to 0 (unlimited) on a server with limited RAM
85% fail
Without a maxmemory limit, Redis will consume all available system memory until the Linux OOM killer terminates the process. This causes data loss and affects other processes on the same server.
-
Restarting Redis without persistence to clear memory
80% fail
If Redis is configured without AOF or RDB persistence, restarting loses all data. Even with persistence, the same data will be reloaded and memory will fill up again immediately after restart.
Error Chain
Preceded by:
Frequently confused with: