5xx Server Errors Explained: 500, 502, 503, and 504
Any HTTP status code starting with 5 means the server acknowledges something went wrong on its end — as opposed to 4xx codes, which mean the client (you, or your request) did something the server didn't like. Here's what each common one actually means.
500 Internal Server Error
The catch-all. Something inside the application threw an unhandled exception — an unexpected null value, a database query that failed, a bug in the code path that request happened to hit. A 500 tells you almost nothing specific; it just means "the server tried to handle this and crashed while doing it."
Where to look: Application logs, right around the timestamp of the error. Most frameworks log a stack trace for unhandled exceptions — that's almost always where the real answer is.
502 Bad Gateway
A 502 means a server acting as a gateway or proxy (a load balancer, reverse proxy, or CDN) received an invalid or malformed response from the upstream server it was trying to talk to. In plain terms: the front door is open, but whoever's supposed to answer behind it said something nonsensical, or didn't speak the expected protocol at all.
Common causes: The application server crashed or isn't running at all (so the proxy gets nothing coherent back), a misconfigured proxy pointing at the wrong port or address, or the backend closing the connection mid-response.
Where to look: Is the application process actually running? Check the proxy's own error logs (nginx, Cloudflare, your load balancer) — they usually log exactly which upstream failed and why.
503 Service Unavailable
A 503 means the server is up and able to respond, but is deliberately refusing to handle the request right now — usually because it's overloaded, in maintenance mode, or a dependency it needs (like a database) is temporarily unreachable. Unlike a 500 or 502, a 503 is often intentional: many frameworks and load balancers return it on purpose when they know they can't serve a good response.
Common causes: Scheduled maintenance mode, a connection pool exhausted under load, auto-scaling not keeping up with a traffic spike, or a health check failing and a load balancer correctly taking an unhealthy instance out of rotation.
Where to look: Resource metrics (CPU, memory, connection counts) around the time of the error, and whether maintenance mode was accidentally left on.
504 Gateway Timeout
A 504 means a proxy or gateway sent a request to an upstream server and simply never got a response back in time — it gave up waiting. This is different from a 502 (which means a response came back, just an invalid one); a 504 means no response came back at all within the allowed time.
Common causes: A slow database query, an external API call that's hanging, or a backend that's simply overloaded and too busy to respond before the proxy's timeout elapses.
Where to look: Slow query logs, and whether a downstream service your app depends on is itself slow or unresponsive.
Quick reference
| Code | Means | Likely cause |
|---|---|---|
| 500 | Unhandled error in the app itself | A bug, an unexpected input, a crash |
| 502 | Proxy got an invalid response from upstream | App server down or misconfigured proxy |
| 503 | Server deliberately refusing the request | Overload, maintenance mode, dependency down |
| 504 | Proxy got no response in time | A slow or hung backend request |
Why it's worth knowing which one you're getting
The specific code tells you where to start looking, which can save a lot of debugging time: a 502 points you at the connection between your proxy and your app, a 504 points you at something slow downstream, and a 503 points you at capacity or deliberate unavailability. An uptime monitor that reports the exact status code — not just "down" — turns an alert into a useful starting clue instead of just a worried notification.
Frequently asked questions
Does WebWatch tell me which status code caused an outage? Yes — each check records the HTTP status code (or the specific connection error if no response came back at all), visible on the monitor's history.
Is a 503 always bad? Not necessarily — a 503 returned intentionally during planned maintenance is working as designed. A 503 you didn't expect is a real problem worth investigating.
What's the difference between a 502 and a 504, really? A 502 means some response came back, but it was invalid or malformed. A 504 means no response came back at all before the proxy gave up waiting. Both point to a problem with the upstream server, just a different flavor of it.