Your VPS keeps crashing despite plenty of RAM and swap because the problem is almost never raw memory capacity — it’s usually a runaway process, a misconfigured kernel setting, or a hardware-level limit like CPU throttling or disk I/O exhaustion. This article explains the actual causes behind out-of-memory (OOM) kills, kernel panics, and sudden reboots, and gives you concrete steps to diagnose and fix them.
What “Plenty of RAM” Actually Means on a VPS
When you see free memory reported as low, that’s often misleading. Linux uses free RAM for caching files and disk blocks, which is a good thing — it speeds up reads and writes. The free -h command shows this as “buff/cache” and it can be reclaimed instantly when an application needs it. The number that matters is available, not free. If your VPS has 4 GB RAM and shows 3.9 GB used, but 3.5 GB of that is cache, you’re not actually out of memory.
Swap is also not a magic fix. Swap is disk space used as an overflow for RAM. If your workload genuinely needs more memory than RAM + swap combined, the kernel’s OOM killer will start terminating processes. But swap can also be the cause of crashes if it’s on a slow disk and the system thrashes — constantly swapping pages in and out — which makes the VPS appear frozen and unresponsive, even though it hasn’t crashed yet.
Why the OOM Killer Targets Innocent Processes
The Linux OOM killer is a last-resort mechanism. When memory is completely exhausted, it picks a process to kill based on a score that considers memory usage, runtime, and how many child processes it has. It often kills the largest process, but not always — it can kill a small but “important” process like sshd or a database, which then triggers a cascade of failures. If your VPS provider monitors the host, they may see the guest as unresponsive and force a reboot, which looks like a crash to you.
Common triggers for OOM kills include:
- Memory leaks in a long-running application (e.g., a Node.js process that grows over days)
- Too many concurrent connections (each Apache/Nginx worker can use 10–50 MB)
- A single large query or batch job that allocates a huge array
- Misconfigured JVM or PHP memory limits that ignore the OS’s available memory
CPU Throttling and Steal Time — The Hidden Crash Cause
VPS providers use hypervisors to share physical hardware. If your neighbor on the same host is using a lot of CPU, your VPS can experience steal time — the hypervisor gives your CPU cycles to someone else. You can see this in top as the %st column. High steal time means your processes run slower, but they still run. However, if your provider enforces a CPU limit and you hit it, the kernel may start throttling your processes, which can cause timeouts, watchdog resets, and apparent crashes.
Similarly, a VPS with 4 vCPUs but a 100% burst limit for only 30 seconds will suddenly slow down dramatically. If your application relies on consistent CPU, it may fail to respond to health checks, and your provider’s monitoring may reboot it. Always check your provider’s fair-use policy and your actual CPU usage over time with mpstat -P ALL 5 or sar.
Disk I/O Exhaustion — The Silent Killer
Even with abundant RAM, if your disk is saturated, everything freezes. This is especially true on shared hosting where other VPSes on the same physical disk are doing heavy writes. Symptoms: iowait in top is high (above 10% consistently), commands hang, and the system becomes unresponsive. The kernel may also mark the filesystem as busy and cause a panic if it can’t write critical data.
To check I/O, use iostat -x 5 and look at %util — if it’s near 100%, your disk is the bottleneck. Common culprits are log rotation, database checkpointing, or a misconfigured backup job that runs at the same time as peak traffic. Moving to an SSD-backed VPS (if you’re on HDD) or adding a separate disk for logs can help.
Kernel Panics and Hardware Errors
Sometimes the crash is not software at all. VPS providers share physical hardware, and a failing host — bad RAM, overheating CPU, or a dying disk — can cause a kernel panic that reboots all guests. You can’t fix this from inside your VPS, but you can check logs: dmesg or /var/log/kern.log may show “Machine Check Exception” or “Hardware Error” entries. If you see those, the problem is on the host, and you should contact your provider and ask to migrate to a different physical node.
Another internal cause is a corrupted kernel or initramfs after an update. If the VPS crashes during boot, you may need to use your provider’s rescue mode to reinstall the kernel. But if the crashes happen randomly after days of uptime, it’s more likely a memory leak or hardware issue.
How to Diagnose the Real Cause (Step-by-Step)
- Check the logs —
journalctl -xe(systemd) ortail -f /var/log/syslog(Debian/Ubuntu) //var/log/messages(RHEL/CentOS). Look for “Out of memory”, “Killed process”, or “panic”. - Monitor memory in real time —
watch -n 1 free -handtop(press M to sort by memory). Note which process grows over time. - Check for memory leaks — If a process’s RSS keeps climbing and never drops, it’s leaking. Restart it and see if uptime improves.
- Look at CPU steal and iowait —
topandiostatfor 10 minutes. If steal > 10% or iowait > 20%, your provider’s hardware is the problem. - Test with a minimal workload — Stop all non-essential services and run a stress test (e.g.,
stress-ng --vm 1 --vm-bytes 2G) to see if it crashes. If it does, it’s a kernel or hardware issue. - Check for swap thrashing —
vmstat 1and look atsiandsocolumns. If they’re constantly non-zero, swap is being hammered.
Frequently Asked Questions
Q: My VPS has 8 GB RAM and 8 GB swap, but it still crashes. Why?
A: Because the total memory (16 GB) is still less than what your workload needs. The OOM killer triggers when both RAM and swap are exhausted. Check the actual memory usage of each process — a single Java app can easily use 10 GB. You need to either reduce the workload or add more RAM, not more swap.
Q: Can I disable the OOM killer to prevent crashes?
A: You can set vm.overcommit_memory=2 and vm.oom_kill_allocating_task=1 to change behavior, but disabling it entirely is dangerous — the system will hang instead of killing a process. Better to fix the root cause, like setting memory limits on containers or using ulimit for processes.
Q: How do I know if my VPS is being throttled by the provider?
A: Run top and look at the %st (steal) column. If it’s consistently above 5–10%, your CPU is being shared heavily. Also check your provider’s dashboard for CPU usage limits — many have burstable plans that throttle after a few minutes of full usage.
Q: Should I add more swap or more RAM?
A: Always add RAM if you can afford it. Swap is 10–100x slower than RAM. If you’re on an SSD, swap is acceptable for occasional overflow, but if you’re constantly using swap, you need more RAM. A good rule: swap should be 1–2x your RAM for hibernation, but for servers, 2–4 GB is usually enough as a safety net.
Q: My VPS crashes only at night. What could cause that?
A: Scheduled jobs — cron tasks, log rotation, backups, or database maintenance. Check /etc/crontab and crontab -l for jobs that run at night. Also check if your provider does nightly backups that might saturate disk I/O.
Q: Can a misconfigured firewall cause crashes?
A: Not directly, but a firewall that blocks certain packets can cause applications to hang and accumulate connections, leading to memory exhaustion. For example, if SYN packets are dropped without RST, the kernel keeps half-open connections in memory. Check netstat -s for SYN_SENT or SYN_RECV counts.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Access the DOM in Angular Safely
- Websites Create QR Code? How It Works
- Evaluate Private Cloud AI Security Operations Platforms
- Space Engineers Server Name & Description Setup
- Tongue Escape Events Schedule: Full Guide
- f/2.8 Telephoto Zoom: What to Consider