Skip to content

Glossary 504 error

What Is a 504 Error (Gateway Timeout)?

  • Technical SEO
Definition

The 504 error (Gateway Timeout) is the HTTP status code returned by a server acting as a gateway or proxy when it does not get a response in time from the server behind it. "Gateway timeout" means the gateway's waiting time ran out. The failure sits between two servers: the gateway waited until its limit and gave up.

A closed door in the foreground and, behind it on the right, a second, smaller door; the dotted path coming from it fades out before it arrives, and above it there is an orange stopwatch, on a dark blue ground.
On this page 12
  1. Origin of the term
  2. How it works
  3. Types and variants
  4. Examples
  5. How to measure it
  6. Advantages and disadvantages
  7. How it differs from related concepts
  8. Criticism and limits
  9. How to apply it, step by step
  10. Best practices
  11. Common mistakes
  12. How this entry was made
In brief

504 error: a proxy or CDN did not get the origin server's response in time. Which timeout fired, and what Google does with the error.

A closed door in the foreground and, behind it on the right, a second, smaller door; the dotted path coming from it fades out before it arrives, and above it there is an orange stopwatch, on a dark blue ground.

Origin of the term

The 504 first appeared in RFC 2068, the HTTP/1.1 specification of January 1997. RFC 1945 for HTTP/1.0, from May 1996, already had the 502 but not the 504. Today it is defined in RFC 9110, from June 2022, section 15.6.5: the gateway "did not receive a timely response" from the server it needed.

The chain of gateways is explained in the entry on the 502 error. The wording depends on the software (nginx titles its page "504 Gateway Time-out"), but the code is the same.

How it works

Every layer that forwards a request decides how long it waits for the next one. If the application takes longer, that layer gives up and answers with a 504. Cloudflare lists a large data query, a long-running process or a server short of resources as causes.

Default values according to each vendor (checked on 13.11.2026):

  • nginx: 60 seconds for proxy_read_timeout and fastcgi_read_timeout, counted between two reads.
  • Apache httpd: ProxyTimeout takes the value of TimeOut, 60 seconds.
  • AWS Application Load Balancer: a 60-second idle timeout and 10 seconds to open the connection.
  • Amazon CloudFront: 30 seconds waiting for the origin's response; for GET and HEAD requests it tries again up to three times.
  • Cloudflare: 125 seconds; on the Enterprise plan, up to 6,000.
  • PHP: 30 seconds for max_execution_time, which by default measures CPU time outside Windows, so time spent waiting on the database does not count.

The shortest limit wins. With nginx at 60 seconds and CloudFront at 30, CloudFront cuts off first. For a POST request, the visitor sees its 504 after 30 seconds; for GET and HEAD, CloudFront retries up to three times and the 504 arrives after about 90. Raising the limit on one layer does nothing if a layer in front of it cuts off sooner.

Which layer gives up first?

Cloudflare answers differently: when its 125 seconds run out, it returns a 524, its own code, which RFC 9110 does not define.

Types and variants

One layer can produce a 504 for different reasons. For its load balancer, AWS lists these: it cannot open the connection within 10 seconds, the target does not respond before the idle timeout, a Lambda function does not answer, or the target announces more bytes than it sends.

CloudFront also returns a 504 when a firewall blocks its traffic to the origin or the origin cannot be reached from the internet. No application is slow in that case: the request never arrives.

With Cloudflare, a 504 carrying its logo came from the origin server; a blank page without the logo was generated by Cloudflare.

Examples

Worked example: an online shop with Cloudflare in front and nginx with PHP-FPM behind it exports the year's orders, and the query runs for 90 seconds without sending anything. At 60 seconds, nginx returns a 504, which shows up with the Cloudflare logo because it came from the origin.

The administrator raises fastcgi_read_timeout to 180 seconds and the export works. Once the file grows and the query passes 125 seconds, the error comes back as a 524, because Cloudflare's limit is now the one that fires. For such processes, Cloudflare suggests a subdomain that is not proxied.

How to measure it

The duration gives the layer away. curl with the -w option and the variables %{http_code} and %{time_total} prints the code and the seconds. With default values, a 504 after 30 seconds on a POST request, or after about 90 on GET and HEAD because of the three attempts, points to CloudFront, one after 60 to nginx or an AWS load balancer, and a 524 at around 125 to Cloudflare. AWS also suggests measuring the time to first byte, TTFB, on each server.

The log confirms it: when the timeout expires, nginx writes "upstream timed out", according to its source code.

In Search Console, the Crawl Stats report separates "Server error (5XX)", where the 504 falls, from "Page timeout", where the page request timed out.

Advantages and disadvantages

A long limit lets slow processes finish; a short one shows the error sooner. AWS recommends setting the application's idle timeout higher than the load balancer's: if the application closes the connection first, the load balancer can return a 502.

For SEO, the 504 follows the general 5xx rule: Google's documentation on status codes (4 February 2026) describes the 500, 502 and 503 separately, but not the 504. Its crawlers slow down, ignore the content and keep indexed URLs, "but eventually dropped", with no deadline. What happens when a server error lasts for days is covered in the entry on the 503 error.

A server that does not answer Googlebot at all is a different case. Google treats "network timeouts, connection reset, and DNS errors similarly to 5xx server errors", but without a response there is no status code. According to its page on network errors, crawling slows down immediately, and indexed URLs that cannot be reached are removed from the index "within days".

How it differs from related concepts

CodeWho waits for whomWhere it is defined
504 Gateway TimeoutThe gateway waits for the origin and runs out of timeRFC 9110, section 15.6.5
502 Bad GatewayThe gateway gets an invalid response from the originRFC 9110, section 15.6.3
524 A timeout occurredCloudflare waits for the origin longer than 125 secondsCloudflare only, outside the standard
408 Request TimeoutThe server waits for the client's complete requestRFC 9110, section 15.5.9

Source: RFC 9110 (June 2022); Cloudflare, "Error 524" (accessed 13.11.2026).

The 500 is the server's generic failure, and the 503 signals overload or maintenance.

Criticism and limits

RFC 9110 asks for a "timely" response but sets no number of seconds. With default values, a response that takes 45 seconds triggers a 504 behind CloudFront and arrives normally behind Cloudflare.

Cloudflare defines the 502 and 504 more broadly than the RFC, as being "unable to establish contact" with the origin server.

How to apply it, step by step

  • Measure with curl how many seconds the 504 takes and compare them with each layer's limit.
  • Find the line from that minute in the proxy log and the slow request in the application log.
  • Move long tasks out of the web request, into a queue or a cron job, and check their status by polling.
  • If a long operation has to stay on the same connection, send at least one byte before the idle timeout runs out, as AWS recommends.
  • Only then adjust the limits, from the application outwards, so that no outer layer cuts off first.
  • After the fix, check host status in Search Console.
  • If you are only visiting the page: reload later; if it works for other people, check your VPN, proxy or DNS, as MDN suggests.

Best practices

  • Log the response time of every request at the origin, as Cloudflare recommends.
  • Keep one document with the actual limit of every layer, from the CDN to PHP.

Common mistakes

  • Raising the nginx limit while a CloudFront distribution in front cuts off at 30 seconds.
  • Looking for a 504 when Cloudflare shows a 524.
  • Assuming PHP's max_execution_time stops a script after 30 seconds of wall-clock time.
  • Assuming Google allows a fixed number of days before dropping URLs that return a 504.

How this entry was made

This entry was written in November 2026 with AI assistance, based on the RFCs, Google and Search Console documentation, and documentation from MDN, nginx, Apache, AWS, Cloudflare and PHP. The time limits were checked on 13.11.2026. It contains no client data.

Manuel Riveiro Rodriguez CEO & Digital Strategist

A technical audit covers this and everything else in one pass.

Request an audit

Frequently asked

Is a 504 error my fault?

The code is generated by a server of the site you are visiting. MDN names one exception: if the page works for other people, check your VPN, proxy or DNS.

Will a 504 gateway timeout fix itself?

It can, if the cause was a load spike; MDN writes that the site may work again later. If it always arrives after the same number of seconds, a request is exceeding one layer's limit.

What is a 504 error on Google?

It is the same response as seen by Googlebot. Google treats it like any 5xx: it slows crawling and, if the error persists, drops the URLs from the index, with no fixed deadline.

What is the difference between a 502 and a 504?

With a 502, the gateway gets an invalid response; with a 504, it gets none in time. The full comparison is in the entry on the 502 error.

Why does a 504 appear in an app or online service?

Apps, from games to online banking, fetch their data from servers through gateways with time limits, just like a website. From the outside, all you can do is wait and retry.

Sources

  1. IETF, RFC 9110 "HTTP Semantics", June 2022, sections 15.5.9 (408), 15.6.3 (502) and 15.6.5 (504).
  2. IETF, RFC 2068 "Hypertext Transfer Protocol -- HTTP/1.1", January 1997, section 10.5.5.
  3. IETF, RFC 1945 "Hypertext Transfer Protocol -- HTTP/1.0", May 1996.
  4. Google, "How HTTP status codes affect Google's crawlers", updated 4 February 2026.
  5. Google, "Debug network and DNS errors for Google's crawlers", updated 18 December 2025.
  6. Search Console Help, "Crawl Stats report".
  7. MDN, "504 Gateway Timeout", last modified 22 June 2026.
  8. nginx, "Module ngx_http_proxy_module", proxy_read_timeout directive.
  9. nginx, "Module ngx_http_fastcgi_module", fastcgi_read_timeout directive.
  10. nginx, source file ngx_http_upstream.c: "upstream timed out" message and 504 response.
  11. nginx, source file ngx_http_special_response.c: "504 Gateway Time-out" page.
  12. Apache HTTP Server 2.4, "mod_proxy", ProxyTimeout directive.
  13. Apache HTTP Server 2.4, "core", TimeOut directive.
  14. AWS, "Troubleshoot your Application Load Balancers", HTTP 504 section.
  15. AWS, "Edit attributes for your Application Load Balancer", Connection idle timeout.
  16. AWS, "HTTP 504 status code (Gateway Timeout)", Amazon CloudFront.
  17. AWS, "Origin settings", Amazon CloudFront, Response timeout.
  18. Cloudflare, "Error 502 or 504", updated 12 October 2026.
  19. Cloudflare, "Error 524", updated 23 July 2026.
  20. Cloudflare, "Connection limits", updated 22 October 2026.
  21. PHP Manual, "Runtime Configuration", max_execution_time directive.