Help Running your server Care and troubleshooting
My server is slow, out of memory or out of disk
Find what's using the CPU, memory or disk, read the logs for what went wrong, clear space safely, and know when it's time to upgrade.
A slow server is almost always one of three things: the CPU is busy, the memory has run out, or the disk is full. Each takes a minute to check. Too busy to log in over SSH? Use the browser console.
The commands, at a glance#
| Command | What it shows | Worth worrying about when |
|---|---|---|
uptime | Load average over 1, 5 and 15 minutes | It stays above the number from nproc |
nproc | How many CPU cores you have | - |
top | Programs, busiest first | One program sits at the top for long |
free -h | Memory in use and available | available is near zero |
df -h | Space on each disk | / is at or near 100% |
df -i | Files on each disk (inodes) | IUse% is at 100% |
systemctl --failed | Services that stopped when they shouldn't | Anything is listed |
journalctl -p err -b | Errors since the last boot | The same error keeps coming back |
What's using the CPU and memory#
topWhile it's open, press P to sort by CPU, M by memory, 1 to see each core, and q to quit. In the %Cpu(s) line, a high wa means programs are waiting on the disk, not the CPU.
htop is easier to read. Install it with sudo apt install -y htop, or on AlmaLinux sudo dnf install -y epel-release && sudo dnf install -y htop.
Out of memory#
free -hRead available, not free: Linux fills spare memory with a file cache and hands it back when a program needs it.
When memory runs out completely, the kernel stops a program to save the rest, often your database or app. Check whether it has:
sudo journalctl -k --no-pager | grep -iE 'out of memory|killed process'Then:
- Find what's growing with
top(pressM). Restarting a leaking app buys time. - Turn down memory settings in databases and Java apps, which take what they're told to.
- Add a swap file as a cushion for short spikes.
- If it's simply too much work for the plan, upgrade (below).
Out of disk#
df -hAt 100% on /, programs can't write and fail in odd ways. Find what's big, a folder at a time, biggest last:
sudo du -xh --max-depth=1 / | sort -hThen go into the biggest, such as /var. ncdu does this interactively: sudo apt install -y ncdu, then sudo ncdu -x /.
The usual suspects
| What | See how much | Clear it |
|---|---|---|
| System journal | journalctl --disk-usage | sudo journalctl --vacuum-size=200M |
| Update packages (Ubuntu / Debian) | du -sh /var/cache/apt | sudo apt clean && sudo apt autoremove -y |
| Update packages (AlmaLinux / Rocky) | du -sh /var/cache/dnf | sudo dnf clean all && sudo dnf autoremove -y |
| Docker images and build cache | sudo docker system df | sudo docker system prune |
| Old logs and backups | sudo du -sh /var/log | Delete old files by hand, never a running program's current log |
docker system prune asks first and leaves running containers and volumes alone. To cap Docker's logs, see Install Docker and Docker Compose.
Space that doesn't come back
If you delete a big file and df doesn't change, a running program still has it open. Find it:
sudo find /proc/*/fd -ls 2>/dev/null | grep '(deleted)'The number after /proc/ is the program's process ID. Restart that program and the space comes back.
If df -h shows space but you still get "disk full", run df -i: millions of tiny files (a cache, a session folder) can use up every inode. Clear that folder out.
Read the logs#
One program's log, in the last hour:
sudo journalctl -u caddy --since "1 hour ago" --no-pagerWhen to upgrade#
Move up when, under normal use, available memory stays low, the load sits above your core count most of the day, or the disk keeps filling with data you need. On a VPS, an upgrade keeps your files and restarts the server once: see Upgrade your plan.
Still slow and none of this explains it? Open a ticket and tell us what you've checked.
Still stuck? Open a ticket and say which guide you followed.