Developer Tools

HTTP 504 Gateway Timeout

5xx Server Error. A server acting as a gateway or proxy didn't receive a timely response from the upstream server.

Runs in your browser. Your files and text never leave your device - nothing is uploaded.

5xx Server Error

What it means

A server acting as a gateway or proxy didn't receive a timely response from the upstream server.

PropertyDetail
Status class5xx Server Error
Defined inRFC 9110, Section 15.6.5
Cacheable by defaultOnly with explicit caching headers: a cache stores it when the response carries Cache-Control (max-age, s-maxage or public) or Expires.
Who needs to actThe site owner, who has to speed up the upstream or adjust timeouts.

What does HTTP 504 Gateway Timeout mean?

HTTP 504 Gateway Timeout means a server acting as a gateway or proxy did not receive a timely response from the upstream server it needed to complete the request. The proxy stopped waiting, usually after its configured timeout. The upstream may still be working on the request, so the action may or may not have happened.

How 504 Gateway Timeout works

A 504 is a disagreement about time. The proxy, whether nginx, a cloud load balancer or a CDN, has a limit on how long it will wait for the upstream, and the upstream exceeded it. nginx's proxy_read_timeout defaults to 60 seconds, and nginx logs 'upstream timed out (110: Connection timed out) while reading response header from upstream' when it fires. Raising the timeout hides the symptom; the durable fix is making the slow operation faster or moving it into a background job. Because the upstream may finish the work after the proxy gives up, blindly retrying a POST can perform the action twice.

Example 504 request and response

GET /reports/annual HTTP/1.1
Host: app.example.com

HTTP/1.1 504 Gateway Timeout
Server: nginx
Content-Type: text/html

nginx waited for the report to render, hit its read timeout and gave up; the report may still be generating behind it.

What causes a 504 Gateway Timeout

  • Slow database queries, missing indexes or locked tables.
  • A slow third-party API that the application waits on synchronously.
  • Long-running work, such as reports or imports, done inside the request.
  • Proxy or load balancer timeouts shorter than the application's real response time.
  • Network or DNS problems between the proxy and the upstream server.

How to fix a 504 Gateway Timeout

If you are a visitor

  • Retry after a short wait, but check before resubmitting a payment or order.
  • If one page always times out, report it; it is a performance problem on the server.

If you run the site

  • Find the slow upstream call with application performance monitoring or slow-query logs.
  • Move long-running work to a background job and return 202 Accepted.
  • Align timeouts across the proxy, load balancer, application server and database.
  • Raise proxy_read_timeout only for routes that genuinely need longer.

504 and SEO

Google handles 504 like other server errors: crawling slows down, and URLs that keep timing out can be removed from the index. Pages that sometimes time out for Googlebot are usually slow for real visitors too.

Related status codes

Tools that help

  • DNS Lookup checks that the upstream hostname resolves to the address you expect.

Frequently asked questions

Sources

Other 5xx Server Error codes

Reviewed by Raja Jahangir · Last reviewed: October 7, 2026