Skip to the content

504 Gateway Timeout

A proxy or gateway waited for the server behind it and got no answer in time. The application can be reached, and it is too slow.

Class
5xx Server error. The request may have been fine, but the server failed to fulfil it.
Defined in
RFC 9110

Share this tool:TwitterFacebookLinkedInWhatsAppEmail

What causes it

When the time limit of the front server runs out before the backend replies: 60 seconds by default in nginx, and similar values in load balancers and CDNs. The backend is busy with a slow database query, is itself waiting for another service, or has more requests than it can work through.

What to do about it

As a visitor: reload once. If the action was a payment or an order, check whether it went through before you try again. The server may have finished the work after the proxy gave up.

As the owner: find the slow part. The logs of the application and the slow query log of the database are the places to look. Raising the timeout of the proxy (proxy_read_timeout in nginx) only helps for requests that are slow by nature, and those are better turned into background jobs that are answered with a 202.

Not to be confused with

502 Bad GatewayThe backend answered wrongly or not at all, without the wait.
503 Service UnavailableThe server declines requests for now.
408 Request TimeoutThe server waited too long for the client.

How Google treats it

Google treats it like any server error: crawling slows down, and pages that keep failing are dropped from the index.

All codes are on the list of HTTP status codes, which can be searched by number and by word.

See all 12