Internal Server Error
ActiveHTTP 500 Internal Server Error indicates the server encountered an unexpected condition that prevented it from fulfilling the request. Defined in RFC 9110 §15.6.1. A generic catch-all for server-side failures.
Description
The 500 Internal Server Error status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the request.
This is a generic error response. When more specific codes are applicable – 502 (bad upstream response), 503 (unavailable), 504 (upstream timeout) – use them instead. 500 is the correct code when your application throws an unhandled exception with no better categorization.
Servers must log detailed error information internally. The client response should contain a stable request ID and a generic message – never a stack trace.
Examples
GET /api/reports/generate HTTP/1.1
Host: api.example.comHTTP/1.1 500 Internal Server Error
Content-Type: application/json
{"error": "internal_error", "message": "An unexpected error occurred. Please try again later.", "request_id": "req_abc123"}Edge Cases
- •Check application logs first – 500 is almost always a stack trace in the application log. If logs are empty, the crash happened before your code ran (Nginx config error, missing runtime).
- •Database connection failure is the most common 500 cause in production – connection pool exhausted, database offline, or network partition. Monitor connection pool metrics.
- •Unhandled promise rejection (Node.js) or uncaught exception – find try/catch gaps around async code. Node.js exits on unhandled rejections by default since v15.
- •OOM-killed processes return nothing to the reverse proxy – which returns 502, not 500. A 500 from the app means the handler threw but the process survived.
- •Missing environment variable – DATABASE_URL, API_KEY undefined in production throws at runtime. Add startup validation that asserts required env vars exist on boot.
- •Never expose stack traces in production 500 responses – they reveal file paths, library versions, dependency names, and internal logic.
- •Include a stable request_id in every 500 response body so support can correlate client-reported errors with server logs.
When You'll See This
- →Unhandled exception in application code
- →Database connection failure
- →Null pointer / undefined reference in request handling
- →Out of memory on the server
Implementation References
| Language | Constant |
|---|---|
| Go | http.StatusInternalServerError |
| Rust | http::StatusCode::INTERNAL_SERVER_ERROR |
| Python | http.HTTPStatus.INTERNAL_SERVER_ERROR |
| Node.js | http.STATUS_CODES[500] |
| .NET | HttpStatusCode.InternalServerError |
| Java | HttpURLConnection.HTTP_INTERNAL_ERROR |
History
Present since HTTP/0.9 (1991). The generic server error. More specific 5xx codes (502, 503, 504) were added later to distinguish different failure modes.
Related Status Codes
FAQ
What causes a 500 Internal Server Error?
A 500 is caused by an unhandled error on the server – bugs in code, database failures, missing configuration, or resource exhaustion. It's never the client's fault.
How do I fix a 500 error?
Check server logs for the actual error. Look for the request ID in the response. Common causes: null references, database timeouts, misconfigured environment variables.