Redis has reached its maxmemory limit and cannot store new data. This occurs when memory usage exceeds the configured limit and the eviction policy cannot free enough space for new operations.
The "OOM Out of memory" error indicates that your Redis instance has exhausted its allocated memory. Redis is an in-memory data store, and when the amount of data stored reaches the maxmemory limit you have configured, Redis cannot accept new write operations. This is a safety mechanism to prevent the server from consuming unlimited system memory. The error typically appears when executing commands that would add new data to the database, though read operations continue to work normally.
Connect to Redis and view memory statistics to understand how much memory is being used:
redis-cli info memoryLook for used_memory_human and compare it to maxmemory. If used_memory is near or exceeding maxmemory, that confirms the OOM condition.
If this is a development or test environment, you can clear the cache:
redis-cli flushallFor production, selectively delete old or unnecessary keys:
redis-cli --bigkeys # Find the largest keys
redis-cli DEL key_name # Remove specific keysChange from noeviction to an eviction policy that automatically removes keys when the limit is reached:
redis-cli CONFIG SET maxmemory-policy allkeys-lruCommon policies:
- allkeys-lru: Evict least recently used keys (recommended for most caches)
- volatile-lru: Evict least recently used keys with expiration only
- allkeys-lfu: Evict least frequently used keys
- volatile-ttl: Evict keys with shortest TTL first
To persist this change, update your redis.conf:
maxmemory-policy allkeys-lruWhen using volatile policies, ensure keys have expiration times:
redis-cli SET mykey "value" EX 3600 # Expires in 1 hour
redis-cli EXPIRE existingkey 3600In your application code:
# Python example
redis_client.setex("cache_key", 3600, "value") # 1 hour TTL
# Node.js example
await redis.setex("cache_key", 3600, "value"); # 1 hour TTLIf your legitimate data exceeds the current limit:
redis-cli CONFIG SET maxmemory 512mbFor permanent changes, edit redis.conf:
maxmemory 512mbThen restart Redis for the configuration to take effect. For managed Redis services (AWS ElastiCache, Google Cloud Memorystore, Azure Cache), scale up the node type through the service console.
Monitor memory usage continuously to catch issues before they cause OOM:
redis-cli --stat # Real-time memory statsSet up alerts when memory usage approaches the maxmemory limit (e.g., at 80% capacity). Most Redis managed services have built-in monitoring. For self-hosted Redis, use tools like Prometheus + Grafana or DataDog to track used_memory over time.
Memory fragmentation can cause issues where Redis reports high memory usage but cannot evict keys effectively. Use redis-cli INFO memory to check the mem_fragmentation_ratio (values above 1.5 indicate fragmentation). You can reduce fragmentation by restarting Redis or using the MEMORY PURGE command. For replicas, eviction policies only apply to the primary instance unless the replica is promoted. High write-rate workloads may accumulate data faster than the eviction background process can remove keys, so monitor write patterns and consider scaling horizontally with sharding if a single instance cannot keep up.
ERR fsync error
How to fix "ERR fsync error" in Redis
CLUSTERDOWN The cluster is down
How to fix 'CLUSTERDOWN The cluster is down' in Redis
ERR Job for redis-server.service failed because a timeout was exceeded
Job for redis-server.service failed because a timeout was exceeded
ERR Unbalanced XREAD list of streams
How to fix "ERR Unbalanced XREAD list" in Redis
ERR syntax error
How to fix "ERR syntax error" in Redis