Quick answer
A 504 error (Gateway Timeout) is an HTTP status code meaning a server acting as a gateway or proxy, such as a CDN or nginx, did not get a timely response from the upstream server it needed. It is a server-side timeout: the shortest timeout on the path decides which hop returns it.
Formula: 504 rate = 504 responses ÷ total requests in the same period × 100
What is a 504 Gateway Timeout error?
A 504 error (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. RFC 9110, the HTTP standard, defines it in exactly those terms. The server that sends you the 504 is not the one that failed to answer: it is the one in the middle that gave up waiting.
On a typical website that middle layer is a CDN or load balancer, a reverse proxy such as nginx, or both. The upstream is your application server, which may itself be waiting on a database or an outside API. Browsers show the same error under several labels: "504 Gateway Timeout", "HTTP Error 504", "Gateway Time-out" or a branded error page from the proxy. They all mean the same thing: somewhere behind the first server, something took longer than that server was willing to wait.
Who returns a 504, and why it is not a client or crawl problem
A 504 is a server-side status in the 5xx class. The visitor's browser, network and cookies are not the cause, so clearing the cache or switching browsers rarely helps, except when the slow upstream happens to recover in the meantime. The same holds for crawlers: a search engine bot that receives a 504 hit the same timeout a human would. Compare a 4xx code such as 406 Not Acceptable, where the server answers promptly but says the request itself cannot be met; a 504 says nothing about the request, only that an answer did not arrive in time.
The key diagnostic fact is that the error page is written by the proxy, not by your application. Your app may still be working on the request and may even finish it after the visitor has already seen the error. That has two consequences:
- Your application logs may show the request as successful while the proxy logs show a 504 for it.
- Any page script on your normal pages, including analytics, never runs, because the browser received the proxy's error page instead.
504 vs 500, 502 and 503
The four common 5xx codes differ by who failed and how. RFC 9110 defines each:
| Code | RFC 9110 meaning | Who generated it | Typical cause | First check |
|---|---|---|---|---|
| 500 Internal Server Error | Server hit an unexpected condition | The application itself | Unhandled exception, bad code path | Application error log and stack trace |
| 502 Bad Gateway | Gateway got an invalid response from upstream | Proxy or load balancer | App crashed, closed the connection or returned garbage | Is the app process running? Proxy error log |
| 503 Service Unavailable | Server temporarily unable to handle the request (overload or maintenance) | App, proxy or platform | Overload, maintenance mode, no healthy backends | Capacity, maintenance flags, Retry-After |
| 504 Gateway Timeout | Gateway did not get a timely response from upstream | Proxy or load balancer | Slow query, slow outside API, exhausted workers | Proxy timeout settings and slow requests |
The quick way to tell 502 from 504: a 502 means the upstream answered badly or hung up; a 504 means it did not answer in time. The generic HTTP 500 error is the application reporting its own failure, so it carries a stack trace in your logs, while a 504 usually does not.
The timeout chain: which hop returns the 504?
Every layer between the browser and the database has its own timeout, and the shortest timeout on the path decides who returns the error. nginx, for example, defaults proxy_read_timeout to 60 seconds; its documentation notes that the timeout applies between two successive reads, not to the whole response.
Sample setup: a CDN in front with a 100-second origin timeout, nginx as reverse proxy with proxy_read_timeout 60s, and an application whose report endpoint runs a database query.
| Scenario | App needs | What happens | Who answers the browser |
|---|---|---|---|
| A: normal day | 45 s | App replies inside both timeouts | App, 200 OK after 45 s |
| B: slow query | 75 s | nginx stops waiting at 60 s and returns 504; the app keeps working until 75 s | nginx, 504 after 60 s |
| C: nginx raised to 90 s | 75 s | App replies at 75 s, inside 90 s and 100 s | App, 200 OK after 75 s |
| D: nginx at 150 s, query 120 s | 120 s | CDN stops waiting at 100 s, before nginx or the app | CDN, its own timeout error after 100 s |
Three rules come out of this table:
- Each outer timeout should be longer than the inner one. In scenario D the CDN's shorter limit makes nginx's 150 seconds useless.
- The work does not stop when the error is sent. In scenario B the database still runs the query for 15 more seconds per request. Under load, retries pile more slow queries on the same database and turn a few 504s into many.
- Raising timeouts treats the symptom. Scenario C "fixes" the error, but a visitor still waits 75 seconds. Fix the slow work first and use longer timeouts only for endpoints that are slow by design, such as exports.
How to fix a 504 error, layer by layer
Work from the edge inwards, because each step narrows where the time is lost.
- Confirm the scope. One URL or all of them? One region or everywhere? Since when? A sitewide 504 that starts at a deploy points to the app; one slow URL points to that endpoint's work.
- CDN or load balancer. Check whether its error page or the origin's is shown. If the edge reports the timeout, compare its origin timeout with the proxy behind it, and request the origin directly to see whether it is slow there too.
- Reverse proxy. In nginx, the error log line "upstream timed out ... while reading response header from upstream" marks a 504 caused by
proxy_read_timeout. Note which upstream and URL, and how long the requests took. - Application. Look for exhausted workers or connection pools (every worker busy, new requests queued), slow outside API calls without their own timeout, and long synchronous jobs that belong in a background queue.
- Database. Check slow-query logs and locks for the window when 504s started. A missing index or a lock held by a batch job is a common root cause behind a "gateway" error.
- Only then adjust timeouts, keeping the outer-longer-than-inner rule, and add a timeout to every outbound call your app makes so a stuck dependency fails fast with a clear error instead of a 504.
For visitors who see a 504 on someone else's site, the honest advice is short: wait a minute and reload. The fix is on the server.
How 504 errors affect SEO and analytics
Search. Google's documentation on HTTP errors says 5xx responses cause its crawlers to temporarily slow down crawling. URLs already indexed are kept at first, but are eventually dropped if they keep returning server errors. A short incident costs some crawl activity; a 504 that persists for days on important URLs can cost index coverage. For how crawl errors show up and get prioritised, see crawl errors.
Analytics. Because the 504 page comes from the proxy, page-script analytics records nothing for those requests. A spike of 504s therefore looks like a drop in pageviews, not like an error, unless you count status codes from server logs.
Measuring it. Treat the 504 share as an error rate: 504 responses ÷ total requests in the same period. Sample data: 1,200 504 responses out of 80,000 requests in an hour is 1,200 ÷ 80,000 = 1.5%. If those 1,200 cluster on one endpoint with 2,000 requests, that endpoint's 504 rate is 60%, which tells you where to look first. Track the rate per endpoint, not only sitewide, and alert on a sustained rise rather than a single spike.
How to see 504 errors in TapCub
TapCub does not monitor uptime or check URLs on a schedule, and its page script cannot see status codes. What it can show depends on where the data comes from.
- Crawlers hitting 5xx. With server-side records, either access records sent to the server events API or Nginx / Apache logs sent to the log import API, Monitoring › Crawl health shows fetches, success rate, 404s and 5xx per search engine, and Web analytics › Bots lists each crawler's most common status code. A run of 504s during an incident shows up there as a dip in success rate.
- The traffic dip humans leave behind. Human visits that received a 504 are not recorded by the page script. In Web analytics › Overview the incident appears as a drop in pageviews and sessions; add the incident window in Configuration › Annotations so the dip is explained later.
- An alert on the drop. In All-platform analytics › Operations › Monitors, a monitor on
pvorsessionschecked hourly can notify you when traffic falls sharply. It only notifies; it does not restart anything. - What TapCub does not show. Monitoring › Errors counts JavaScript errors in the browser, not HTTP status codes. The data import page skips 4xx and 5xx lines from human requests when building pageviews. Count human 504s from your proxy logs.
Sources
- IETF. RFC 9110: HTTP Semantics, section 15.6 — definitions of 500, 502, 503 and 504. Checked 2026-11-28.
- MDN Web Docs. 504 Gateway Timeout. Checked 2026-11-28.
- nginx documentation. Module ngx_http_proxy_module —
proxy_read_timeout,proxy_connect_timeoutandproxy_send_timeoutdefault to 60 s. Checked 2026-11-28. - Google Search Central. How HTTP status codes, and network and DNS errors affect Google Search — 5xx slows crawling; persistent errors drop URLs. Checked 2026-11-28.
Was this explanation clear?
We use your answers to fix and expand this page.
Couldn’t send. Please try again in a minute.
Thanks for the feedback. We’ll use it to improve this page.You’ve already sent feedback on this page. Thanks.

Product Experience Specialist
Writes about product experience, practical workflows, and growth, turning complex processes into clear steps for everyday decisions.