Storming Solutions

Digital Hub / Web Development

502, 503 and 504 Errors: Gateway Problems Explained

Updated 15 November 2026

Jump to section

502, 503, and 504 are all 5xx server errors, and each points at a different failure between servers. A 502 Bad Gateway means one server got an invalid response from another it relies on. A 503 Service Unavailable means the server is not ready, usually down for maintenance or overloaded. A 504 Gateway Timeout means a server waited on another and got no reply in time. None of the three is the visitor's fault.

What do 502, 503, and 504 have in common?

All three are 5xx codes, which MDN classes as server error responses (500 to 599). The server, not the visitor, failed to complete the request. The person seeing the error did nothing wrong.

Two of them, 502 and 504, are gateway errors. Modern sites rarely run on one machine; a request often passes through a proxy or CDN to an upstream server that does the real work. When that hand-off fails, you get a gateway error.

A 503 is different in cause but shares the theme. The server is reachable, but it is deliberately or temporarily not answering, because it is busy or being worked on.

502 Bad Gateway: an invalid response upstream

A 502 Bad Gateway means a server acting as a gateway or proxy received an invalid response from the upstream server it depends on. The front-facing server is fine; the one behind it misbehaved.

MDN describes 502 as a case where a server "received an invalid response from the upstream server" (MDN, updated June 2026). It calls this a catch-all much like a 500, but specific to the point in the request chain where the failure happened.

In practice a 502 often clears on its own, when the upstream server hiccuped only briefly. A 502 that persists needs the server owner or host to investigate, because it points at a broken or misconfigured back-end service.

503 Service Unavailable: not ready right now

A 503 Service Unavailable means the server is not ready to handle the request, most often because it is down for maintenance or overloaded. It is the one 5xx error that is frequently intentional.

MDN names both causes, a server "down for maintenance or overloaded", and notes the response should carry a Retry-After header with the estimated recovery time, where possible. During maintenance, administrators may route all traffic to a 503 maintenance page on purpose, and some software updates do it automatically.

For SEO this distinction matters. Google's guidance allows a 503 if you must take the site down for 1 to 2 days, so search knows the outage is temporary. Past that, Google slows its crawling, and URLs that keep returning server errors are eventually dropped from its index.

504 Gateway Timeout: no reply in time

A 504 Gateway Timeout means a server acting as a gateway or proxy waited for the upstream server and got no response in time. It is the close cousin of a 502, split by one detail.

MDN draws the line clearly. A 502 means the gateway received an invalid response, while a 504 means it "did not get a response in time from the upstream server". One got a bad answer; the other got no answer before the clock ran out.

A 504 usually points at an upstream server that is overloaded or too slow to respond, or a timeout set too tight. Like a 502, a persistent 504 needs the host or server administrator to trace the slow or unresponsive service.

How do you fix a 502, 503, or 504?

You fix these by working out whether the outage is momentary, planned, or a real fault, then acting on the right one. Start by waiting a minute and reloading, since brief 502 and 504 blips often clear themselves.

Code Likely cause First move
502 Upstream server sent a bad response Reload; if it persists, contact the host
503 Maintenance or overload Wait for maintenance; if unplanned, check server load
504 Upstream server too slow or unresponsive Reload; if it persists, investigate the slow service

Source: code definitions from MDN, retrieved September 2026. The first-move column is our troubleshooting advice.

If the error stays, the fix belongs to whoever runs the server. Check whether a recent deployment, a plugin, or a traffic spike overloaded the back-end, and whether your host is having an outage of its own. Set up monitoring so you hear about an outage before your customers do. The first thing we check on a sudden 502 or 504 is whether the host has a wider incident. One broken upstream service can take many sites down at once.

Frequently asked questions

What is the difference between a 502 and a 504 error?

Both are gateway errors, but they differ by what the gateway received. A 502 Bad Gateway means the server got an invalid response from the upstream server it relies on. A 504 Gateway Timeout means it got no response in time at all. MDN draws exactly this line: 502 is a bad answer, 504 is no answer before the timeout runs out.

Is a 503 error bad for SEO?

A 503 lasting a day or two is the least harmful way to take a site offline, though Google prefers limiting features over going dark. It tells Google to check back rather than drop your page.

If the 503 persists, Google slows its crawling and eventually drops those URLs from its index. Keep outages short and use a 503, not a blank error page.

Why does my site show a 502 error that then disappears?

Because the upstream server hiccuped briefly and then recovered. A momentary 502 often means one back-end service stalled for a second under load or during a restart, then answered normally again. If it clears on reload and stays gone, there is usually nothing to fix. A 502 that keeps returning, though, points at a real back-end fault worth investigating.

Are 502, 503, and 504 errors my fault or the host's?

They are server-side errors, so the fault sits with the server or host, not the visitor. A 503 may be your own planned maintenance, while 502 and 504 usually point at an overloaded or misconfigured back-end, or a host incident. The person seeing the error did nothing wrong. The fix belongs to whoever runs the server or the hosting.

How long should I wait before worrying about a 502 or 504?

Give it a minute or two and reload, since brief gateway blips clear on their own. If the error persists past a few minutes across different devices and networks, it is a real outage that needs attention. Check whether your host reports an incident, and whether a recent deployment or traffic spike overloaded the server behind your site.

Getting the servers talking again

Storming Solutions builds custom-coded websites and maintains existing ones for Malaysian businesses. Tracing a gateway error to the overloaded service or host incident behind it is part of that maintenance. We would rather find the failing upstream service than leave a client refreshing a broken page.

Seeing a 502, 503, or 504 on your site now? Send us the URL on WhatsApp for a quick look, read the quick map of status codes to place it, or talk to us about web development and reliable hosting.

WhatsAppCall 011-2333 6888