Skip to main content

Troubleshooting a Website Not Working on a Self-Managed VPS (Linux, Container and Storage VPS)

Updated over a week ago

This guide explains how to troubleshoot a website that is not working on a self-managed VPS, even though:

  • The VPS is accessible via SSH

  • The hosting provider confirms no infrastructure issues

  • The server is online

  • Only the website is failing

1. Initial Quick Checks

If your VPS is accessible via SSH or Emergency Console, you should run:

uptime
free -m
df -h
systemctl --failed

What to Look For

  • High load average

  • Memory exhaustion

  • Disk space at 100%

  • Failed system services

These four commands often reveal the root cause within minutes.

2. Website Not Loading at All

Symptom

  • “This site can’t be reached”

  • Browser timeout

  • Connection refused

Step 1: Check Web Server Status

For Apache:

systemctl status apache2

or:

systemctl status httpd

For Nginx:

systemctl status nginx

If stopped:

systemctl restart nginx

If it fails to start:

journalctl -xe

Step 2: Verify Ports 80 and 443 Are Listening

ss -tulnp | grep :80
ss -tulnp | grep :443

If no output appears, the web server is not listening.

Step 3: Check Firewall Rules

If using UFW:

ufw status

If using iptables:

iptables -L -n

Ensure ports 80 (HTTP) and 443 (HTTPS) are open.

Step 4: Verify DNS

From your local machine:

nslookup yourdomain.com

Confirm:

  • Correct IP address;

  • DNS propagation complete - if records are changed there might be 1-24 hours propagation (time depends on the changed DNS record);

  • A record properly configured and your domain is pointed to your VPS IP address.

3. 500 Internal Server Error

Common Causes

  • PHP crash

  • Permission errors

  • Corrupt .htaccess

  • Database issues

  • Disk full

Check Web Server Logs

Apache:

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

Nginx:

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

Logs typically provide the exact cause.

Check PHP-FPM

systemctl status php8.1-fpm

If stopped:

systemctl restart php8.1-fpm

Also review PHP logs:

/var/log/php8.1-fpm.log

Check File Permissions

Correct typical configuration:

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

Incorrect ownership is a very common issue after deployments or file transfers.

Check Disk Space

df -h

If disk usage is 100%, remove unnecessary files such as:

  • Old backups

  • Large logs

  • Cache directories

4. 502 Bad Gateway (Common with Nginx)

Most Common Cause

PHP-FPM is not running.

Restart services:

systemctl restart php8.1-fpm systemctl restart nginx

Also verify the socket path in your Nginx configuration matches:

/run/php/php8.1-fpm.sock

5. 503 Service Unavailable

Possible Causes

  • Server overload

  • Maintenance mode

  • PHP max_children limit reached

Check PHP pool configuration:

grep max_children /etc/php/8.1/fpm/pool.d/www.conf

Increase the value if necessary and restart PHP-FPM.

6. Database Connection Errors

Example Message

“Error establishing database connection”

Step 1: Check Database Service

systemctl status mysql

or

systemctl status mariadb

Restart if necessary:

systemctl restart mysql

Step 2: Verify Credentials

Check application configuration files such as:

  • .env

  • wp-config.php

  • config.php

Test database login manually:

mysql -u dbuser -p

Step 3: Check for Corruption

mysqlcheck -u root -p --all-databases

7. Website Extremely Slow

Check System Load

top

Look for:

  • High CPU usage

  • Excessive PHP processes

  • MySQL consuming 100% CPU

  • Memory exhaustion

Check Memory and Swap

free -m

If swap usage is high, the server likely lacks sufficient RAM.

Possible solutions:

  • Upgrade VPS RAM

  • Optimize MySQL configuration

  • Reduce PHP worker processes

Conclusion

If your VPS is accessible but the website is down, the issue is almost always related to:

  • A stopped service

  • Resource exhaustion

  • Misconfiguration

  • Application-level failure

Systematically checking services, logs, disk space, and resource usage will resolve the majority of incidents quickly.

Did this answer your question?