5xx Server Error
Safe to retry
500 Internal Server Error
The server hit an unhandled condition. It is a catch-all, not a diagnosis.
What causes it
- An unhandled exception in application code.
- A database connection failure or a missing environment variable in the deployed build.
- A syntax error in server configuration, or a bad `.htaccess` directive.
- File permissions preventing a script from executing.
How to fix it
- The status tells you nothing — go straight to the server error log. In nginx that is usually `/var/log/nginx/error.log`; in a PaaS, the platform log stream.
- Reproduce with the same request locally and turn on stack traces in a non-production environment only.
- Never leak a stack trace to the client; return a request ID and log the detail server-side.
At a glance
- Class
- 5xx Server Error
- Reference
- RFC 9110 §15.6.1
- Standardised
- Yes
- Retry the request?
- Yes, with backoff
Other 5xx server error codes
- 501 Not Implemented
- 502 Bad Gateway
- 503 Service Unavailable
- 504 Gateway Timeout
- 505 HTTP Version Not Supported
- 506 Variant Also Negotiates
- 507 Insufficient Storage
- 508 Loop Detected
- 510 Not Extended
- 511 Network Authentication Required
- 520 Web Server Returned an Unknown Error
- 521 Web Server Is Down
- 522 Connection Timed Out
- 523 Origin Is Unreachable
- 524 A Timeout Occurred
- 525 SSL Handshake Failed
- 526 Invalid SSL Certificate