Can't save in background: fork: Cannot allocate memory Redis Origin: Data OSI layer 7 · Application Last updated 5 Nov 2026

Redis: # Can't save in background: fork: Cannot allocate memory / WARNING overcommit_memory is set to 0!

Redis couldn't fork to write an RDB/AOF snapshot because the OS refused to allocate memory.

Exact message you may see Can't save in background: fork: Cannot allocate memoryBackground saving errorWARNING overcommit_memory is set to 0! Background save may fail under low memory condition# Can't save in background: fork: Cannot allocate memoryRedis fork Cannot allocate memory
Seen on: Redis Linux

Meaning

Set vm.overcommit_memory = 1 (sudo sysctl vm.overcommit_memory=1 and persist in /etc/sysctl.conf), ensure there is enough free RAM + swap, reduce dataset size, and disable THP. Forking duplicates page tables, so large instances need headroom (up to 2× in write-heavy loads).

Common causes

  • vm.overcommit_memory=0 with a large dataset
  • Not enough free RAM
  • Containers with tight memory limits
  • THP enabled
  • Frequent snapshots with heavy writes

⚡ Quick fix

  1. sudo sysctl vm.overcommit_memory=1 and add to /etc/sysctl.conf
  2. Give the instance more RAM/headroom
  3. Disable THP; tune save intervals

Detailed fix by platform

Linux

  1. sudo sysctl vm.overcommit_memory=1 && echo "vm.overcommit_memory = 1" | sudo tee -a /etc/sysctl.conf

How to diagnose

  1. Overcommit — Value?
  2. RAM — Headroom?
  3. Limits — Container memory?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Data. Errors that are often confused with or caused by this one (click to open):

Bad file format reading the append only file / AOF corrupted — Redis: Bad file format reading the append only file: make a backup of your AOF file, then use ./redis-check-aof --fix <filename> (Redis)Bad file format readi…Cannot allocate memory — fork: Cannot allocate memory / ENOMEM (Linux)Cannot allocate memoryClient output buffer limit reached (scheduled to be closed) — Redis: Client id=12 addr=10.0.0.5:51234 scheduled to be closed ASAP for overcoming of output buffer limits (Redis)Client output buffer …Composer: Allowed memory size exhausted — Composer: PHP Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer (Laravel)Composer: Allowed mem…Failed opening the temp RDB file / Permission denied writing dump.rdb — Redis: # Failed opening the temp RDB file temp-1234.rdb (in server root dir /var/lib/redis) for saving: Permission denied (Redis)Failed opening the te…heap out of memory — FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory (Node.js)heap out of memoryJupyter kernel died — The kernel appears to have died. It will restart automatically. (Python)Jupyter kernel diedKeys disappear: maxmemory eviction (allkeys-lru) — Redis: evicted_keys growing — keys vanish unexpectedly because maxmemory is reached and a volatile/allkeys eviction policy is active (Redis)Keys disappear: maxme…Can't sav…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.