Fix Linux Killing Your Server (OOM Killer / Out of Memory)
Out of memory: Killed processoom-killerserver randomly stopsIf your server process vanishes with no crash log, Linux probably killed it to save the system from running out of RAM — the "OOM killer". Here's how to confirm and prevent it, including the container-specific memory limits people forget about.
Confirm it was the OOM killer
Check the kernel log for the tell-tale message:
dmesg | grep -i 'killed process'
journalctl -k | grep -i oom
A line like Out of memory: Killed process 1234 (java) confirms the kernel killed your server to free RAM.
Why it happens
The total RAM requested by everything on the box exceeded what's available. Common causes: a server allocated more than the machine has (e.g. -Xmx too high), too many servers on one box, or a memory leak.
| Cause | How to spot it | Fix |
|---|---|---|
| One server allocated too much | -Xmx near/over total RAM | Lower -Xmx, leave OS headroom |
| Too many servers on one box | Combined limits exceed RAM | Move one off, or upgrade the plan |
| A memory leak | RAM climbs steadily until the kill | Find and update the leaking app |
| Container memory limit hit | Killed well below host RAM | Raise the container/cgroup memory limit |
| No swap on a tight box | Kills on brief spikes | Add a small swap file as a buffer |
How to stop it
- Lower your allocation — leave 1–2 GB for the OS; never give a server all system RAM.
- Add swap — a few GB of swap absorbs spikes (slower, but prevents kills).
- Run fewer services per box, or move to a plan with more RAM.
- Find leaks — if usage only ever climbs, profile the app/plugins.
# add 4G of swap
fallocate -l 4G /swapfile && chmod 600 /swapfile
mkswap /swapfile && swapon /swapfile
The OOM killer targets the process using the most memory — often your game server, even if a different process caused the spike. Fixing total RAM pressure is the real solution.
Confirm with dmesg, then leave headroom for the OS, add swap, and run within the RAM you actually have.
Container-specific memory limits
If your server runs in Docker or under a panel like Pterodactyl, a cgroup memory limit set on the container can trigger its own OOM kill independent of the host's total RAM — even if the host itself has plenty free. Check the container's configured memory limit, not just system-wide RAM — docker inspect shows a container's memory limit, and systemctl show shows a systemd service's MemoryMax.
How to prevent OOM kills for good
- Size
-Xmx(or the panel's RAM limit) comfortably below the container/host's actual memory, never equal to it. - Watch memory trend over days, not just a snapshot — a slow leak looks fine until it isn't.
- Set
vm.overcommit_memoryand swappiness sensibly rather than leaving kernel defaults untouched on a memory-constrained VPS.
Related errors
If the process fails to even start rather than being killed later, see fixing "cannot allocate memory" (fork failed). For Minecraft specifically running out of heap, see fixing Minecraft "out of memory" (Java heap space). To check usage generally, see how to check CPU, RAM and disk usage on Linux.
Right-sized RAM, no surprises
Our plans give your server the RAM it needs with room to spare — no OOM kills, protected in Frankfurt.
Frequently asked questions
Why does my game server randomly stop with no crash?
Linux's OOM killer probably terminated it to free RAM. Check dmesg for "Killed process". It means the machine ran out of memory and the kernel killed the biggest process — often your server.
How do I stop the OOM killer killing my server?
Don't over-allocate RAM (leave 1–2 GB for the OS), add some swap to absorb spikes, run fewer services per machine, or move to a plan with more memory. Fix any memory leaks.
Does adding swap fix out-of-memory?
Swap absorbs short spikes and prevents kills, but it's much slower than RAM. It's a safety net, not a substitute for having enough actual memory for your workload.
Can Docker or a panel kill my server for memory even if the host has RAM free?
Yes — a per-container cgroup memory limit (set by Docker, Pterodactyl, or systemd) enforces its own ceiling independent of total host RAM. Check the container/service memory limit specifically, not just system-wide usage.
What's the difference between the OOM killer and a normal crash?
A normal crash usually leaves an error/crash log written by the application itself. An OOM kill is abrupt — the kernel sends SIGKILL with no chance for the app to log anything, which is why it looks like the process just vanished.
How much RAM headroom should I leave for the OS?
A rough rule of thumb is 1-2 GB free for the OS and background processes on a small VPS, more on a busier box running a panel, database, or multiple services alongside the game server.
Related articles
Fix SSH "Connection refused" / "Connection timed out"
SSH "connection refused" vs "timed out" — what each means and the exact steps to fix them.
Read fix Linux & VPSFix "Permission denied" on Linux (chmod & chown Explained)
"Permission denied" on a script or file? Understand chmod/chown and fix it the right way.
Read fix Linux & VPSHow to Check CPU, RAM & Disk Usage on a Linux Server
The essential commands to check CPU, RAM and disk on Linux — and find what's eating them.
Read fix