cs@vps-hosting.org

VPS Troubleshooting & Disaster Recovery – Keeping Your Server Online

No matter how well you set up your VPS, things will go wrong—server crashes, security breaches, data corruption, or unexpected spikes in traffic. In this chapter, we’ll cover real-world VPS troubleshooting, diagnosing performance issues, preventing downtime, and disaster recovery strategies to bring your server back online quickly.


7.1 Diagnosing VPS Performance Issues

1️⃣ Checking CPU & RAM Usage

If your VPS is slow or unresponsive, the first step is to check CPU, memory, and disk usage.

Check System Resource Usage with top or htop


top

or


htop

Look at:

  • %CPU → High values mean processes are overloading the CPU.
  • %MEM → High values indicate low available RAM.

Check Running Processes with ps

Find which processes are consuming the most resources:

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

Check Disk Space with df


df -h

If / or /var is full, it may cause server crashes.

Check I/O Bottlenecks with iotop



iotop

If a process is using too much disk I/O, it can slow down everything.


2️⃣ Fixing High CPU & Memory Usage

If your VPS is maxing out CPU or RAM:

Kill High-Usage Processes


kill -9 <PID>

Limit CPU Usage with cpulimit


apt install cpulimit -y
cpulimit -p <PID> -l 50

This limits a process to 50% CPU usage.

Increase Swap Memory (If RAM is Full)


fallocate -l 2G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo '/swapfile none swap sw 0 0' >> /etc/fstab

7.2 Network Issues – Fixing Slow or Unreachable VPS

1️⃣ Checking Network Status

First, verify network connectivity:


ping 8.8.8.8 -c 4

If it fails, check your network configuration.

Check Open Ports


netstat -tulnp

Ensure your web server (Nginx/Apache) is listening on the correct port.

Check Firewall Rules

ufw status
iptables -L -n -v

If needed, allow traffic:

ufw allow 80/tcp
ufw allow 443/tcp

7.3 Fixing Web Server (Nginx/Apache) Issues

1️⃣ Check if the Web Server is Running


systemctl status nginx
systemctl status apache2

2️⃣ Restart the Web Server


systemctl restart nginx
systemctl restart apache2

3️⃣ Check Logs for Errors

tail -f /var/log/nginx/error.log
tail -f /var/log/apache2/error.log

4️⃣ Fixing “502 Bad Gateway” Errors

If Nginx shows 502 Bad Gateway, restart PHP:


systemctl restart php-fpm

5️⃣ Fixing “403 Forbidden” Errors

Check file permissions:


chmod -R 755 /var/www/html/
chown -R www-data:www-data /var/www/html/


7.4 Fixing Database (MySQL/PostgreSQL) Issues

1️⃣ Check if MySQL/PostgreSQL is Running


systemctl status mysql
systemctl status postgresql

Restart if needed:


systemctl restart mysql
systemctl restart postgresql

2️⃣ Fixing “Too Many Connections” Error

If MySQL rejects connections:

SHOW STATUS WHERE variable_name = 'Threads_connected';

Increase limits:

SET GLOBAL max_connections = 500;

3️⃣ Repair Corrupt MySQL Database


mysqlcheck -r database_name

7.5 Handling Server Crashes & Recovery

1️⃣ Rebooting a Frozen VPS

If the VPS is completely unresponsive:


reboot -f

If that doesn’t work, use your VPS provider’s control panel to force restart.

2️⃣ Recovering from a Kernel Panic

If your VPS crashes due to a bad kernel update, reboot into an older kernel:

  1. Reboot and select Advanced Options in GRUB.
  2. Choose an older kernel version.
  3. If successful, remove the faulty kernel:

dpkg –list | grep linux-image
apt remove linux-image-
update-grub
reboot


7.6 Preventing Downtime with Backup & Restore Strategies

1️⃣ Automated Daily Backups

Use rsync to back up files to another VPS:


rsync -avz /var/www/ user@backup-server:/backups/

2️⃣ MySQL Automatic Backups

Create a cron job to backup MySQL databases every night:


crontab -e

Add:


0 3 * * * mysqldump -u root -p'yourpassword' --all-databases > /backup/db-$(date +\%F).sql

3️⃣ Restoring from Backup

If a server crash happens, restore from backup:


scp user@backup-server:/backups/db-latest.sql /tmp/
mysql -u root -p < /tmp/db-latest.sql

7.7 Protecting Your VPS from DDoS Attacks

1️⃣ Install Fail2Ban to Block Attackers

apt install fail2ban -y

Enable it:

systemctl enable fail2ban --now

2️⃣ Use Cloudflare for DDoS Protection

  • Set up Cloudflare free plan.
  • Enable “Under Attack Mode” to filter traffic.

3️⃣ Block Malicious Traffic with IPTables


iptables -A INPUT -s <malicious-ip> -j DROP

Conclusion

Troubleshooting is a critical skill for VPS hosting. By learning how to diagnose issues, fix common problems, and prevent downtime, you can keep your VPS online and secure.

In the next chapter, we’ll explore Optimizing VPS for Speed & Performance, including advanced caching, fine-tuning database queries, and leveraging CDNs for lightning-fast websites.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free Worldwide shipping

On all orders above $50

Easy 30 days returns

30 days money back guarantee

International Warranty

Offered in the country of usage

100% Secure Checkout

PayPal / MasterCard / Visa