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.
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 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=0with a large dataset- Not enough free RAM
- Containers with tight memory limits
- THP enabled
- Frequent snapshots with heavy writes
⚡ Quick fix
sudo sysctl vm.overcommit_memory=1and add to /etc/sysctl.conf- Give the instance more RAM/headroom
- Disable THP; tune
saveintervals
Detailed fix by platform
Linux
sudo sysctl vm.overcommit_memory=1 && echo "vm.overcommit_memory = 1" | sudo tee -a /etc/sysctl.conf
How to diagnose
- Overcommit — Value?
- RAM — Headroom?
- 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:
Similar errors
- 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>
- Cannot allocate memory fork: Cannot allocate memory / ENOMEM
- Client 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
Most viewed in Redis
- READONLY You can't write against a read only replica Redis: READONLY You can't write against a read only replica
- Celery with Redis: tasks run twice (visibility_timeout) Celery: Task executed twice / Restoring unacked messages — Redis broker visibility_timeout shorter than task ETA
- MaxRetriesPerRequestError: Reached the max retries per request limit ioredis: MaxRetriesPerRequestError: Reached the max retries per request limit (which is 20). Refer to "maxRetriesPerRequest" option for details
Other ways to find it
Where this error sits
Origin: Data. Errors that are often confused with or caused by this one (click to open):
🧠 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.
Report a correction or suggest an improvement
Last updated 5 Nov 2026