Redis: 'OOM Command Not Allowed When Used Memory > maxmemory'

Redis hit its memory cap and the eviction policy is 'noeviction' — so writes fail. Pick a policy and stop storing unbounded keys without TTLs.

What you'll see

Root causes

Eviction policy is noeviction

The default on some distros: when full, Redis refuses writes rather than evicting.

Keys with no TTL accumulating forever

Sessions, job queues, and rate-limit counters written without EXPIRE grow unbounded.

Fix it

  1. Check the current policy and memory
    redis-cli CONFIG GET maxmemory* | head; redis-cli INFO memory | grep used_memory_human
  2. Set a cache-appropriate policy (config AND runtime)
    redis-cli CONFIG SET maxmemory-policy allkeys-lru
  3. Find key classes without TTLs
    redis-cli --bigkeys; redis-cli DBSIZE
  4. Add TTLs at write time
    SET session:abc data EX 3600

Field note

allkeys-lru for pure cache, volatile-lru if some keys must survive. Never noeviction for a cache tier — that setting is for durable stores you babysit.

Common questions

Why did Redis stop accepting writes?

maxmemory is reached and the policy is noeviction: Redis refuses writes rather than delete data. Check INFO memory (used_memory vs maxmemory_human) and pick a policy appropriate to your use — allkeys-lru for caches, noeviction only when eviction would lose real data.

Which eviction policy should a cache use?

allkeys-lru for general caches (evicts least-recently-used keys, any key eligible); volatile-lru only when some keys must never be evicted (mark the rest with TTLs). noeviction on a cache just moves the failure into your app.

Ship it right the first time

Our most-documented failures, packaged as ready-to-ship starter kits: Docker, Kubernetes, and Terraform.

Browse the template store →

One-time. Yours to modify. Instant download from the NinjaOps template store.

Get new fixes by email

One short email when new fixes and production templates drop. No spam, unsubscribe anytime.

Partner pick — sponsored

Vultr — our lab-environment pick for this stack

Spin up a cloud server in 60 seconds and reproduce this fix yourself — pay by the hour.

Get Vultr →
Also vetted

Sentry — Free tier: see the exact line of code that broke, before users report it.

Get Sentry →

We earn a commission if you buy through our links — it never costs you extra. More vetted tools on our picks hub · comparing clouds? DigitalOcean vs Vultr and vs AWS · full deals: DigitalOcean · Vultr · NordLayer · Semrush