Common Causes

How to Debug

500 errors are intentionally vague to users for security — the details are in the server logs:

# Apache error log (typical locations)
/var/log/apache2/error.log
/var/log/httpd/error_log

# Nginx
/var/log/nginx/error.log

# PHP (check php.ini for error_log location)
/var/log/php_errors.log

# Enable PHP errors temporarily (development only!)
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
⚠️ Never display errors in production. Error messages can expose file paths, database credentials, and code structure to attackers.

500 vs 502 vs 503

CodeMeaningCommon Cause
500Unhandled server errorCode bug, PHP fatal error
502Bad Gateway — upstream server returned bad responseApp server crashed, PHP-FPM down
503Service unavailableOverloaded server, maintenance
504Gateway Timeout — upstream took too longSlow database query, API timeout

Prevention