Fix: VPS High CPU Usage or Server Overloaded

Estimated reading: 2 minutes

If your VPS feels slow, unresponsive, or you’re getting 502/503 errors, high CPU usage is likely the cause. Here’s how to identify the process responsible and fix it.

Step 1: Check Current CPU and Memory Usage

top

Press P to sort by CPU usage. The top processes are the culprits. Press q to exit. For a more readable view, use:

htop

If htop is not installed: apt install htop -y

Step 2: Check System Load Average

uptime

The load average shows 1, 5, and 15 minute averages. A healthy load average should be below the number of CPU cores on your VPS. Check your core count with:

nproc

If load average is consistently above your core count, the server is overloaded.

Step 3: Identify the Problematic Process

Find which process is using the most CPU:

ps aux --sort=-%cpu | head -10

Common high-CPU processes and what to do:

  • php-fpm / php: A WordPress plugin or script is running loops — disable recently installed plugins and check cron jobs
  • mysql / mysqld: A slow or unoptimized query — check MySQL slow query log
  • nginx / apache2: High traffic or a DDoS — check access logs and consider rate limiting
  • python / node: A runaway script — restart or kill the process

Step 4: Kill a Runaway Process

If a process is consuming all CPU and needs to be stopped, get its PID from top or ps aux and kill it:

kill -9 PID

Replace PID with the actual process ID number.

Step 5: Check for Malware or Crypto Miners

Sudden unexplained high CPU on a VPS is sometimes caused by a compromised server running a crypto miner. Look for suspicious process names like xmrig, minerd, or random strings:

ps aux | grep -i -E "xmrig|minerd|kswapd0|kdevtmpfsi"

If you find malware, the safest fix is to snapshot your data, wipe the VPS, and reinstall from a clean image.

Step 6: Restart Overloaded Services

# Restart Nginx
systemctl restart nginx

# Restart Apache
systemctl restart apache2

# Restart PHP-FPM (replace 8.2 with your version)
systemctl restart php8.2-fpm

# Restart MySQL
systemctl restart mysql

Need More Resources?

If CPU is consistently maxed out under normal load, your VPS plan may need an upgrade. Contact Veerhost support at veerhost.com/support.