When browsing or maintaining a website, HTTP response status codes inform client browsers whether a web request succeeded or failed. While 200 OK means smooth operation, encountering 4xx client errors and 5xx server errors can be frustrating if you don't know where to look.
In this guide, we break down the four most common website errors (403, 404, 500, and 502) and provide immediate command-line fixes for your RivinCloud VPS.
1. HTTP 403: Forbidden
What It Means:
The web server understood the request, but refuses to authorize access. The resource exists, but permission is denied.
Common Causes:
- Incorrect Linux file permissions: The web server process (
www-dataornginx) does not have read permissions on the directory or file. - Missing Directory Index: Nginx is configured to serve a directory with
autoindex off, but noindex.htmlorindex.phpfile exists inside that folder. - IP blocking / .htaccess restriction: A firewall, security plugin, or
.htaccessrule is explicitly denying access to your IP address.
How to Fix:
# Correct ownership to web server user
sudo chown -R www-data:www-data /var/www/html/
# Set standard directories to 755 and files to 644
sudo find /var/www/html -type d -exec chmod 755 {} \;
sudo find /var/www/html -type f -exec chmod 644 {} \;
2. HTTP 404: Not Found
What It Means:
The web server is reachable and running, but it cannot locate the requested file or URI path on the filesystem.
Common Causes:
- Typo in URL or wrong root path: The
rootdirective in your Nginx/Apache configuration points to a non-existent or misnamed directory. - Missing URL Rewrite Rules: For Single-Page Apps (React/Vue) or WordPress permalinks, Nginx needs a fallback rewrite rule to send requests to
index.htmlorindex.php.
How to Fix in Nginx:
Ensure your location / block includes try_files:
location / {
try_files $uri $uri/ /index.php?$args;
}
3. HTTP 500: Internal Server Error
What It Means:
The web server encountered an unexpected condition or runtime crash that prevented it from fulfilling the request.
Common Causes:
- PHP Syntax / Fatal Error: A syntax error, missing PHP extension, or unhandled exception crashed the script.
- Malformed
.htaccess(Apache): A typo or unsupported directive in.htaccess. - Database Connection Failure: The application failed to authenticate to MySQL with the configured database credentials.
How to Diagnose:
Check your web server and PHP error logs immediately:
# For Nginx:
sudo tail -n 25 /var/log/nginx/error.log
# For Apache:
sudo tail -n 25 /var/log/apache2/error.log
# For PHP-FPM:
sudo tail -n 25 /var/log/php8.2-fpm.log
4. HTTP 502: Bad Gateway
What It Means:
The web server (acting as a reverse proxy) attempted to forward the request to an upstream backend daemon (like PHP-FPM, Node.js, Python Gunicorn, or Docker), but received an invalid response or the backend was completely unreachable.
Common Causes:
- Backend Daemon Is Stopped: PHP-FPM or your Node.js application crashed or is not running.
- Socket Path Mismatch: Nginx is configured to look for
/run/php/php8.1-fpm.sockwhen the server actually hasphp8.2-fpmrunning. - Port Conflict / Timeout: The backend service timed out or hung during execution.
How to Fix:
# Check if PHP-FPM is running
sudo systemctl status php8.2-fpm
sudo systemctl restart php8.2-fpm
# Check if Node.js / Python PM2 app is running
pm2 status
Common Mistakes
- Guessing instead of reading log files: Server logs tell you the exact line number, file name, and error message causing the issue.
- Granting 777 permissions: Never use
chmod -R 777to fix 403 errors; this creates severe security vulnerabilities.
Summary Troubleshooting Checklist
| Error Code | First Command to Run |
|---|---|
| 403 Forbidden | sudo chmod -R 755 /var/www/html |
| 404 Not Found | Verify root directive in /etc/nginx/sites-available/ |
| 500 Internal | sudo tail -n 50 /var/log/nginx/error.log |
| 502 Bad Gateway | sudo systemctl status php*-fpm |
Conclusion
Understanding HTTP status codes turns mysterious website crashes into quick, solvable fixes. Keep your RivinCloud VPS logs monitored to maintain 99.9% uptime!
