fork: Cannot allocate memory / ENOMEM
The kernel refused a memory allocation — RAM and swap are exhausted, or overcommit/cgroup limits block it.
Seen on:
Linux
Meaning
Unlike the OOM killer (which kills a process), this fails the allocation: new processes can’t fork, commands fail. Small VPSs without swap, memory leaks, or a container memory limit cause it.
Common causes
- RAM full and no swap
- Memory leak in a long-running process
- vm.overcommit_memory=2 strict accounting
- Container/cgroup memory limit
⚡ Quick fix
- Find the biggest processes: ps aux --sort=-%mem | head
- Add swap on small servers
- Fix the leak or raise the limit
Detailed fix by platform
Linux
- bash
free -h ps aux --sort=-%mem | head sudo fallocate -l 2G /swapfile && sudo chmod 600 /swapfile && sudo mkswap /swapfile && sudo swapon /swapfile
How to diagnose
- Memory — free -h
- Top users — ps sorted by memory
- Limits — cgroup/container limits, sysctl vm.overcommit_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
- 0xC0000005 The application was unable to start correctly (0xc0000005) / Exception code 0xc0000005 access violation
- double free or corruption C/C++: free(): double free detected / double free or corruption (out) — Aborted (core dumped)
- EADDRINUSE Error: listen EADDRINUSE: address already in use :::3000
Most viewed in Linux
Other ways to find it
🧠 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 7 Oct 2026