Writing

504 Gateway Timeout

Published 17 September 2026

A 504 gateway timeout is the most-blamed-on-the-network error there is, and one of the least deserving. Before anything else: the fact you got a 504 at all proves your connection worked. The waiting happened between two of their servers, long after your request had safely arrived.

What a status code proves

This is the part that settles most arguments. For any HTTP status code to reach you, five things had to succeed in order:

  1. The hostname resolved to an address.
  2. A TCP connection opened to it.
  3. TLS negotiated, if it was https.
  4. Your request was delivered intact.
  5. A response travelled back to you.

A 504 is a reply. Something at the other end composed it and sent it to you successfully. If the network between you and that server were broken, you would not have a number at all: you would have a timeout with no response, which is a different thing entirely and looks different.

So what actually timed out?

The clue is in the word gateway. A 504 comes from a machine acting as a middleman: a reverse proxy, a load balancer, an API gateway, a CDN edge. That machine took your request and passed it to a backend server behind it. Then it waited. The backend did not answer in time, so the gateway gave up and told you so.

Both machines belong to them. Your request finished its journey when it reached the gateway; everything after that is an internal conversation you are not part of.

StageWho owns itDid it work?
You → their gatewayYou and the internetYes, or there would be no 504
Their gateway → their backendThemNo: this is what timed out
Their gateway → youYou and the internetYes: the 504 arrived

This is why a 504 can take thirty seconds to appear and still be proof the network is healthy. You were connected, patiently, for the entire duration of somebody else's internal wait.

504 versus 502 versus 503

These three get used interchangeably in tickets and they mean genuinely different things.

CodeWhat the gateway experienced
502 Bad GatewayThe backend answered, but with something that was not usable HTTP. It spoke, and what it said was nonsense.
504 Gateway TimeoutThe backend did not answer at all within the limit. Silence, not nonsense.
503 Service UnavailableUsually no backend was involved. The server itself decided it would not serve you: overloaded, or in maintenance.

A 503 is often deliberate. A 502 and a 504 are not.

If you own the server

The question is never "why is nginx erroring": nginx is reporting faithfully. It is "what is the backend doing for that long?"

If you do not own it

There is nothing on your side to fix, and that is worth establishing quickly so the time goes somewhere useful.

Get the verdict in one request. The HTTP status checker fetches the URL, follows every redirect, and says plainly whether the fault is yours, theirs, or genuinely the network: plus the headers that change the answer, like cf-ray and retry-after.

Check a URL

When the network really is to blame

Not never: just not here. The failures that genuinely implicate the network are the ones with no status code at all, because no round trip ever completed:

If you have a 504, you have none of those. You have a reply, which means the network delivered your request and delivered their answer. The next conversation belongs to whoever owns the backend.