HTTP
HTTP 500Internal Server Error
HTTP 500 Internal Server Error is the generic response when the server hit an unexpected condition and could not complete the request. It almost always means an application exception, a configuration error such as a bad .htaccess directive, a permissions problem or a failed dependency such as a database. The server's error log contains the actual reason.
What 500 means
The server accepted the request, tried to handle it, and something broke that it did not have a more specific code for. The response body is usually a generic error page precisely so that details of the failure are not exposed to visitors. The details are in the log.
Common causes
| Cause | Where it shows up |
|---|---|
| Unhandled exception in the application | Application log, PHP error log, stack trace |
Syntax error or unsupported directive in .htaccess | Apache error log: "Invalid command" |
| Wrong file permissions or ownership (CGI/PHP refusing to run) | Error log: "Permission denied", suEXEC/suPHP messages |
| PHP memory or execution time limit reached | "Allowed memory size exhausted", "Maximum execution time" |
| Database down, wrong credentials, connection limit | Application log: connection refused / access denied |
| Missing dependency after deployment | "Class not found", module load errors |
| Disk full | Logs stop; sessions and uploads fail |
| Misconfigured reverse proxy returning 500 on backend failure | Proxy log (though 502/504 are more typical) |
Diagnosis for operators
- Read the error log first. Apache:
/var/log/apache2/error.logor/var/log/httpd/error_log; nginx:/var/log/nginx/error.log; PHP-FPM: its own log; IIS: Event Viewer and failed-request tracing. cPanel hosts expose "Errors" in the panel. - What changed? A deploy, a plugin update, a config edit, a PHP version switch, a certificate renewal script.
- Isolate configuration: rename
.htaccesstemporarily; if the 500 disappears, bisect the file. - Check permissions: files 644, directories 755, owned by the correct user; the chmod calculator shows the meaning of each mode.
- Check resources:
df -hfor disk, PHP-FPM status for workers, database connection counts. - Reproduce with curl to see headers the browser hides:
curl -i https://example.com/failing-pagePrevention
- Catch exceptions at the application boundary and log them with context.
- Return specific codes where they apply: 400/422 for bad input, 503 for maintenance and overload, 502/504 for upstream failures.
- Monitor error-log volume; a spike is the earliest warning.
Frequently asked questions
How do I fix a 500 error as a visitor?
Reload once. If it persists, wait a few minutes; it is almost always a server-side problem you cannot fix. If a form submission triggered it, do not resubmit repeatedly. Clearing cookies helps only in the rare case that a corrupted session causes the error.
My WordPress site shows a 500 error. Where do I start?
Enable WP_DEBUG_LOG or check the host's error log; the message names the plugin or theme file. Rename the plugins folder to disable all plugins, then re-enable one at a time. Check .htaccess by temporarily renaming it. Check PHP memory limit and version.
Why does the page work sometimes and 500 other times?
Intermittent 500s point to resource limits (PHP workers, memory, database connections), a flaky upstream dependency, or a race condition. Correlate the timestamps in the error log with load.