StarDomain

Common VPS Issues and Solutions

Common VPS Issues and Solutions

This guide covers frequently encountered problems on {{COMPANY_NAME}} VPS servers and their solutions. Use this as a quick reference when troubleshooting.


1. High CPU Usage

Symptoms

  • Slow website loading
  • SSH commands take long to execute
  • Load average above CPU core count

Diagnosis

bash
# Check load average
uptime

# Find CPU-heavy processes
top -bn1 -o %CPU | head -15

# Check for cryptocurrency miners or malware
ps aux | grep -E "xmrig|minerd|cryptonight"

Solutions

  1. Kill runaway processes:
bash
kill -9 PID
  1. Optimize your application:

- Enable caching (Redis, Memcached)

- Optimize database queries

- Use PHP OPcache for PHP applications

  1. Check for malware:
bash
sudo apt install clamav -y
sudo freshclam
sudo clamscan -r /var/www/ --infected
  1. Upgrade your VPS if legitimate workload exceeds capacity

2. High Memory Usage / OOM Kills

Symptoms

  • Services crash and restart unexpectedly
  • "Cannot allocate memory" errors
  • High swap usage

Diagnosis

bash
# Check memory
free -h

# Check OOM killer log
dmesg | grep -i oom | tail -5

# Memory usage by process
ps aux --sort=-%mem | head -10

Solutions

  1. Add or increase swap space:
bash
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
  1. Tune MySQL/MariaDB memory:

Edit /etc/mysql/mysql.conf.d/mysqld.cnf:

ini
innodb_buffer_pool_size = 256M    # reduce for low-memory VPS
max_connections = 50
key_buffer_size = 16M
  1. Tune PHP-FPM:

Edit your PHP-FPM pool config:

ini
pm = ondemand
pm.max_children = 10
pm.process_idle_timeout = 10s
  1. Restart services to free memory:
bash
sudo systemctl restart mysql
sudo systemctl restart php*-fpm
sudo systemctl restart nginx

3. Disk Space Full

Symptoms

  • "No space left on device" errors
  • Services fail to start
  • Cannot create or save files

Diagnosis

bash
# Check disk usage
df -h

# Find large directories
du -h / --max-depth=1 | sort -hr | head -10

# Find large files
find / -type f -size +100M -exec ls -lh {} ; 2>/dev/null

Solutions

  1. Clean package cache:
bash
sudo apt clean
sudo apt autoremove -y
  1. Rotate and compress logs:
bash
sudo journalctl --vacuum-size=100M
sudo find /var/log -name "*.gz" -mtime +30 -delete
  1. Remove old kernels:
bash
sudo apt autoremove --purge
  1. Clear temporary files:
bash
sudo rm -rf /tmp/*
sudo rm -rf /var/tmp/*
  1. Check for large database binary logs:
bash
sudo ls -lh /var/lib/mysql/*-bin.*
# Purge old binary logs
mysql -e "PURGE BINARY LOGS BEFORE DATE(NOW() - INTERVAL 3 DAY);"

4. Website Returns 502 Bad Gateway

Symptoms

  • Browser shows "502 Bad Gateway" error
  • Nginx error log shows upstream connection errors

Diagnosis

bash
# Check PHP-FPM status
sudo systemctl status php*-fpm

# Check Nginx error log
sudo tail -20 /var/log/nginx/error.log

Solutions

  1. Restart PHP-FPM:
bash
sudo systemctl restart php8.2-fpm   # adjust version number
  1. Check socket/port configuration matches between Nginx and PHP-FPM
  1. Increase PHP-FPM children:
ini
pm.max_children = 20
  1. Check PHP-FPM logs:
bash
sudo tail -30 /var/log/php8.2-fpm.log

5. MySQL/MariaDB Won't Start

Symptoms

  • "Can't connect to local MySQL server" error
  • Service fails to start

Diagnosis

bash
sudo systemctl status mysql
sudo tail -50 /var/log/mysql/error.log

Solutions

  1. Disk full preventing startup:
bash
df -h /var/lib/mysql
# Free space, then restart
sudo systemctl start mysql
  1. Corrupted InnoDB logs:
bash
# Add to mysqld.cnf temporarily
innodb_force_recovery = 1
# Start MySQL, export data, remove the setting, reimport
  1. Permission issues:
bash
sudo chown -R mysql:mysql /var/lib/mysql
sudo systemctl start mysql

6. Cannot Send Emails

Symptoms

  • Application email not delivered
  • SMTP connection timeout

Diagnosis

bash
# Check if port 25 is open
telnet smtp.gmail.com 587

# Check mail logs
sudo tail -30 /var/log/mail.log

Solutions

  1. Use an SMTP relay (recommended for VPS) instead of sending directly
  2. Check if your VPS provider blocks port 25 -- many providers do by default
  3. Configure SPF, DKIM, and DMARC records for your domain
  4. Use a transactional email service like Amazon SES, Mailgun, or SMTP2GO

7. Permission Denied Errors

Symptoms

  • Web application shows permission errors
  • Cannot read or write files

Solutions

bash
# Fix web directory ownership
sudo chown -R www-data:www-data /var/www/html

# Fix permissions
sudo find /var/www/html -type d -exec chmod 755 {} ;
sudo find /var/www/html -type f -exec chmod 644 {} ;

# For writable directories (uploads, cache)
sudo chmod 775 /var/www/html/storage
sudo chmod 775 /var/www/html/cache

8. Time Zone Incorrect

Symptoms

  • Logs show wrong timestamps
  • Cron jobs run at unexpected times

Solution

bash
# Check current timezone
timedatectl

# Set timezone
sudo timedatectl set-timezone Asia/Kolkata

# Verify
date

9. DNS Resolution Not Working

Symptoms

  • apt update fails with "Temporary failure resolving..."
  • Cannot reach external services

Solutions

bash
# Check DNS config
cat /etc/resolv.conf

# Set reliable DNS servers
sudo nano /etc/resolv.conf

Add:

nameserver 8.8.8.8
nameserver 1.1.1.1

For permanent DNS on systems using systemd-resolved:

bash
sudo nano /etc/systemd/resolved.conf
# Set: DNS=8.8.8.8 1.1.1.1
sudo systemctl restart systemd-resolved

Quick Troubleshooting Checklist

  1. Is the VPS running? (check client area)
  2. Can you ping the VPS IP?
  3. Is the service (SSH, web, database) running?
  4. Is the disk full? (df -h)
  5. Is memory exhausted? (free -h)
  6. Are firewall rules correct? (ufw status)
  7. What do the logs say? (/var/log/syslog, service-specific logs)

  • VPS Not Responding: Troubleshooting Guide
  • Monitoring VPS Resources (CPU, RAM, Disk)
  • Setting Up a Firewall on Your VPS (UFW/iptables)

Need further help? Contact our support team at {{SUPPORT_EMAIL}} or open a ticket at {{SUPPORT_URL}}.