What HTTP 500 means
The generic server-side failure: an unhandled exception, a bug, a crashed database query. The problem isn’t in the request itself, though a particular input may have triggered the bug. The details are in the server logs, not in the response, which shouldn’t expose stack traces in production.
How to fix a 500 error
- Check the application log first: the stack trace shows the failing line.
-
On Apache with PHP, a syntax error in
.htaccesscauses 500 for every request. - Missing environment variables or database credentials after a deploy are a frequent cause.
- If it only happens sometimes, check memory limits and connection pool exhaustion.
Retrying
Sometimes. Retry idempotent requests (GET, PUT, DELETE) once or twice; don’t blindly retry a POST that may have partly succeeded.
Example response
HTTP/1.1 500 Internal Server Error
Date: Wed, 21 Oct 2026 10:30:00 GMT
Content-Type: application/json
How to return 500
res.status(500).json({ error: 'Internal Server Error' });
from fastapi import HTTPException
raise HTTPException(status_code=500, detail="Internal Server Error")
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
location /private/ {
return 500;
}
Related status codes
- 502 Bad Gateway : A proxy or gateway got an invalid response from the upstream server.
- 503 Service Unavailable : The server is temporarily unable to handle requests, usually overload or maintenance.
- 504 Gateway Timeout : A proxy or gateway didn’t get a response from the upstream server in time.
Other 5xx status codes
501 Not Implemented · 502 Bad Gateway · 503 Service Unavailable · 504 Gateway Timeout · 505 HTTP Version Not Supported · 507 Insufficient Storage · 508 Loop Detected · 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
See the full list of HTTP status codes.
Sources
Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.
Frequently asked questions
What does HTTP 500 Internal Server Error mean?
HTTP 500 Internal Server Error means the server hit an unexpected error and couldn’t complete the request. The generic server-side failure: an unhandled exception, a bug, a crashed database query. The problem isn’t in the request itself, though a particular input may have triggered the bug. The details are in the server logs, not in the response, which shouldn’t expose stack traces in production.
How do I fix HTTP 500?
Check the application log first: the stack trace shows the failing line. On Apache with PHP, a syntax error in .htaccess causes 500 for every request. Missing environment variables or database credentials after a deploy are a frequent cause. If it only happens sometimes, check memory limits and connection pool exhaustion.