Both HTTP 500 and HTTP 502 are 5xx Server Error status codes, but they identify failures at different layers of modern multi-tier web architectures.
Architecture boundary
[Client] ---> [Reverse Proxy / Gateway] ---> [Upstream Application]
| |
502 Bad Gateway 500 Internal Server Error
- HTTP 500 Internal Server Error: Generated directly by the upstream application. The application process received the request, attempted to process it, and encountered an uncaught runtime exception or database error.
- HTTP 502 Bad Gateway: Generated by the reverse proxy. The proxy attempted to connect to the upstream application, but the connection was refused, dropped prematurely, or returned invalid HTTP protocol frames.
How to test with curl
curl -i https://api.example.test/v1/status
Key takeaway
Inspect application stack traces for 500 Internal Server Error and proxy error logs (connection drops, process crashes) for 502 Bad Gateway.