What 500 means
The server hit an unexpected problem and couldn’t complete the request. It’s the catch-all server error: the code says nothing about the cause, only that it’s on the server side.
When servers send it
When application code throws an exception that nothing catches, or a server misconfiguration stops the request being handled.
Common causes
- An uncaught exception or bug in the application.
- A database query failing (a missing table, a bad migration).
- A missing environment variable or config value.
- A syntax error in a server config file such as
.htaccess. - File permission problems on scripts.
How to fix it as a developer
- Look in the server or application logs first: the stack trace is there, not in the response.
- Reproduce the request with the same body and headers (copy it as curl from developer tools).
- Catch expected errors and return the right 4xx instead, such as 400, 404 or 409.
- Never send stack traces to users in production. Log them, and return a request id the user can quote.
How to fix it as a visitor
- Reload the page after a minute.
- Try again later: it’s the site’s problem, not yours.
- If it keeps happening, contact the site with the time and what you were doing.
Related codes
- 502 Bad Gateway: A proxy or load balancer got an invalid response, or none at all, from the server behind it.
- 503 Service Unavailable: The server can’t handle the request right now, usually because it’s overloaded or down for maintenance.
- 504 Gateway Timeout: A proxy or load balancer gave up waiting for the server behind it to reply.
- 501 Not Implemented: The server doesn’t support the feature needed to answer, such as an unknown request method.
Where it’s defined
500 Internal Server Error is defined in RFC 9110, section 15.6.1. It’s a 5xx code, the server error class: the server, or something behind it, failed to deal with a valid request.
Other 5xx codes
501 Not Implemented · 502 Bad Gateway · 503 Service Unavailable · 504 Gateway Timeout · 505 HTTP Version Not Supported · 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
Or search them all in the HTTP status code list.