Troubleshooting guide
Linux OOM killer: why it killed your process
When Linux runs out of memory it picks a process and kills it. The kernel log records exactly what happened, and the victim is not always the culprit.
3 min read10 sectionsUpdated
On this page
Common causes
- A memory leak that grows until the host is exhausted.
- A traffic spike multiplying workers, each with its own memory.
- Cgroup limits, where an OOM kill occurs although the host has plenty free.
- Large database caches configured too high for the host.
- No swap at all on a host with sharp spikes.
Diagnose it
The kernel log tells you whether the kill was global or in a cgroup, and what was using memory.
# What was killed, and why
journalctl -k --since "2 hours ago" | grep -iE 'out of memory|oom-kill|killed process'
# Memory right now: "available" is the useful column
free -m
# Biggest consumers
ps -eo pid,rss,cmd --sort=-rss | head -10
# Score the kernel would use for a process
cat /proc/$(pgrep -o nginx)/oom_scoreFixes
Fix the source: profile leaks, cap worker counts by available memory, and size caches to leave headroom. Protect essential services in systemd using OOMScoreAdjust=-500, though nothing should run at -1000 unless you are sure. Set MemoryMax= on less important services so they fail first. A small amount of swap can absorb short spikes. On a large fleet, systemd-oomd can act earlier.
Catch it automatically
Alert on any OOM kill: these are always worth seeing. Track "available" memory per host, and restarts per service in infrastructure monitoring. A slow upward line in the days before a kill means a leak, and APM connects it to a release.
Why was my database killed when another app leaked?
The OOM killer prefers large processes, and databases are often the largest.
Is free memory near zero a problem?
No. Linux uses spare memory as cache. Look at the available column instead.
Should I disable overcommit?
Usually not. It can make allocations fail in programs that do not expect it.
Related reading
- Redis: OOM command not allowed when used memory > maxmemory: Fix the Redis OOM error "command not allowed when used memory > maxmemory": eviction policies, finding big keys, TTLs, fragmentation and when to add memory.
- Zombie processes on Linux: what they are and how to clear them: What Linux zombie processes are, why kill cannot remove them, how to find the parent that is not reaping children, and how an init process fixes containers.
- JavaScript heap out of memory: how to fix it in Node.js: Fix FATAL ERROR: JavaScript heap out of memory. Set --max-old-space-size correctly, handle build-time failures and find runtime leaks with heap snapshots.
- High CPU usage on a Linux server: find the cause: Diagnose high CPU on a Linux server: read top, load, steal and iowait, find the busy process and thread, profile it and spot throttling.
- ERR_CONNECTION_TIMED_OUT: why a site will not load: Why browsers show ERR_CONNECTION_TIMED_OUT, how to tell a client problem from a server one, and the firewall, DNS and server checks that find the cause.
- What is CLS (Cumulative Layout Shift)?: Cumulative Layout Shift explained: how shifts are scored, session windows, the 0.1 threshold, the usual causes such as images and ads, and how to find them.
Watch your own site and services with VitalRix
Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.