Troubleshooting
Common VPS issues and their solutions. Learn to troubleshoot connectivity, performance, security, and application problems with step-by-step guides.
- Basic Linux command line knowledge
- Access to VPS (physical or remote)
- Understanding of your system configuration
- Backup of important data (recommended)
- Patience and systematic approach to problem-solving
SSH connection problems are among the most common issues VPS users face. Most problems can be resolved with systematic troubleshooting.
Common SSH Issues:
- Connection refused or timeout
- Permission denied errors
- Host key verification failed
- SSH service not running
- Firewall blocking connections
# Check SSH service status
sudo systemctl status sshd
sudo systemctl is-enabled sshd
# Check SSH port
sudo netstat -tlnp | grep :22
sudo ss -tlnp | grep :22
# Test SSH from localhost
ssh localhost
# Check SSH configuration
sudo sshd -t
# Check firewall rules
sudo ufw status
sudo iptables -L
# Check SSH logs
sudo tail -f /var/log/auth.log
sudo tail -f /var/log/secure
# Test connection with verbose output
ssh -v user@your-server-ip
# Clear known hosts if host key changed
ssh-keygen -R your-server-ip
# Check DNS resolution
nslookup your-server-ip
dig your-server-ipServices failing to start or restart can prevent applications from working properly. Common issues include configuration errors, dependency problems, and permission issues.
Common Service Issues:
- Configuration syntax errors
- Missing dependencies
- Permission problems
- Port conflicts
- Resource limitations
# Check service status
sudo systemctl status apache2
sudo systemctl status nginx
sudo systemctl status mysql
# Check service logs
sudo journalctl -u apache2 -n 50
sudo journalctl -u nginx -f
sudo journalctl -u mysql --since "1 hour ago"
# Test configuration files
sudo apache2ctl configtest
sudo nginx -t
sudo mysqld --help | head -10
# Check for port conflicts
sudo netstat -tlnp | grep :80
sudo netstat -tlnp | grep :443
sudo lsof -i :3306
# Check disk space
df -h
du -sh /var/log/*
# Check memory usage
free -h
ps aux --sort=-%mem | head -10
# Restart services
sudo systemctl restart apache2
sudo systemctl restart nginx
sudo systemctl restart mysqlSlow performance can be caused by various factors including resource constraints, misconfigurations, and application issues.
Performance Problem Causes:
- High CPU usage
- Memory exhaustion
- Disk I/O bottlenecks
- Network congestion
- Misconfigured applications
# Monitor system resources
top
htop
free -h
# Check CPU usage
mpstat 1
sar -u 1 5
# Check memory usage
vmstat 1
cat /proc/meminfo
# Check disk I/O
iostat -x 1
iotop
# Check network usage
ifstat 1
nload
# Check swap usage
swapon -s
cat /proc/swaps
# Check load average
uptime
cat /proc/loadavg
# Monitor specific processes
ps aux | grep apache
ps aux | grep mysql
ps aux | grep nginx
# Check system limits
ulimit -a
cat /etc/security/limits.confDatabase connection problems can prevent applications from accessing data. Issues often involve authentication, network connectivity, or resource limitations.
Database Connection Problems:
- Authentication failures
- Connection limits exceeded
- Network connectivity issues
- Configuration errors
- Resource exhaustion
# Test database connections
# MySQL/MariaDB
mysql -u root -p -e "SELECT VERSION();"
mysql -u username -p database_name -e "SELECT 1;"
# PostgreSQL
psql -U username -d database_name -h localhost -c "SELECT version();"
# MongoDB
mongosh --eval "db.stats()"
# Check database service status
sudo systemctl status mysql
sudo systemctl status postgresql
sudo systemctl status mongod
# Check database logs
sudo tail -f /var/log/mysql/error.log
sudo tail -f /var/log/postgresql/postgresql-12-main.log
sudo tail -f /var/log/mongodb/mongod.log
# Check connection limits
# MySQL
mysql -u root -p -e "SHOW VARIABLES LIKE 'max_connections';"
mysql -u root -p -e "SHOW PROCESSLIST;"
# PostgreSQL
psql -U postgres -c "SHOW max_connections;"
psql -U postgres -c "SELECT * FROM pg_stat_activity;"
# Check network connectivity to database
telnet localhost 3306
telnet localhost 5432
telnet localhost 27017Web server issues can result in websites being unavailable or slow to respond. Common problems include configuration errors, resource limitations, and security issues.
Web Server Issues:
- Configuration syntax errors
- Permission problems
- Resource exhaustion
- SSL/TLS configuration issues
- PHP-FPM problems
# Test web server configuration
sudo apache2ctl configtest
sudo nginx -t
# Check web server status
sudo systemctl status apache2
sudo systemctl status nginx
# Check web server logs
sudo tail -f /var/log/apache2/error.log
sudo tail -f /var/log/apache2/access.log
sudo tail -f /var/log/nginx/error.log
sudo tail -f /var/log/nginx/access.log
# Check PHP-FPM status (if using PHP)
sudo systemctl status php7.4-fpm
sudo tail -f /var/log/php7.4-fpm.log
# Test web server response
curl -I http://localhost
curl -I https://localhost
# Check SSL certificate
openssl s_client -connect localhost:443 -servername localhost
# Check file permissions
ls -la /var/www/html/
sudo find /var/www -type f -name "*.php" -exec ls -la {} ;
# Check disk space for web files
du -sh /var/www/*
df -h /var/www
# Restart web services
sudo systemctl restart apache2
sudo systemctl restart nginx
sudo systemctl restart php7.4-fpmNetwork problems can affect connectivity to your VPS and between services. Issues may involve DNS, routing, firewall rules, or network interface configuration.
Network Problem Types:
- DNS resolution failures
- Routing problems
- Firewall blocking traffic
- Network interface issues
- Bandwidth exhaustion
# Check network interfaces
ip addr show
ifconfig -a
# Test network connectivity
ping -c 4 google.com
ping -c 4 8.8.8.8
# Check DNS resolution
nslookup google.com
dig google.com
# Check routing table
ip route show
route -n
# Check firewall rules
sudo ufw status
sudo iptables -L -n -v
# Check network services
sudo netstat -tlnp
sudo ss -tlnp
# Monitor network traffic
sudo iftop
sudo nload
# Check network configuration files
cat /etc/resolv.conf
cat /etc/hosts
cat /etc/network/interfaces
# Test specific ports
telnet localhost 80
telnet localhost 443
telnet localhost 22
# Check bandwidth usage
vnstat
iftopIf you suspect a security incident, it's important to respond quickly and systematically to contain the damage and prevent further compromise.
Security Incident Steps:
- Isolate affected systems
- Preserve evidence
- Assess the damage
- Remove malicious content
- Strengthen security
# Check for suspicious processes
ps aux | grep -v root | head -20
ps aux --forest
# Check for unusual network connections
netstat -antp | grep ESTABLISHED
ss -antp | grep ESTABLISHED
# Check system logs for suspicious activity
sudo grep "Failed password" /var/log/auth.log
sudo grep "Invalid user" /var/log/auth.log
# Check for unauthorized users
cat /etc/passwd | grep -v nologin | grep -v false | grep -v sync
awk -F: '($3 >= 1000) {print $1}' /etc/passwd
# Check for world-writable files
find / -type f -perm -o+w ! -path "/proc/*" 2>/dev/null | head -20
# Check for hidden files in user directories
find /home -name ".*" -type f | head -20
# Check cron jobs for suspicious entries
crontab -l
ls -la /etc/cron.*
# Scan for rootkits
sudo rkhunter --check
sudo chkrootkit
# Check file integrity
sudo aide --check
# Backup important logs before analysis
sudo cp /var/log/auth.log /var/log/auth.log.backup
sudo cp /var/log/syslog /var/log/syslog.backupWhen systems become unresponsive or severely compromised, you may need to perform recovery procedures to restore normal operation.
Recovery Scenarios:
- Boot failures
- Filesystem corruption
- Severe security incidents
- Configuration disasters
- Hardware failures
# Boot into recovery mode
# At GRUB menu, select Advanced Options
# Choose recovery mode kernel
# Mount filesystem in recovery mode
mount -o remount,rw /
mount -a
# Check filesystem integrity
sudo fsck /dev/sda1
sudo e2fsck -f /dev/sda1
# Repair package database
sudo dpkg --configure -a
sudo apt install -f
# Restore from backup
sudo tar -xzf /backups/system_backup.tar.gz -C /
# Reset root password (if locked out)
# Boot into recovery mode
mount -o remount,rw /
passwd root
# Check system logs for errors
sudo journalctl -p err --since "1 day ago"
# Verify system services
sudo systemctl list-units --failed
sudo systemctl reset-failed
# Clean up temporary files
sudo find /tmp -type f -mtime +7 -delete
sudo find /var/tmp -type f -mtime +7 -delete
# Reboot system
sudo rebootCan't find what you're looking for? Our support team is here to help.