TapCub is live — analytics, insights and live chat, free on one platform
Glossary

504 Error (Gateway Timeout): What It Means and How to Fix It

A 504 error means a gateway or proxy gave up waiting for the upstream server. How it differs from 500, 502 and 503, which hop in a timeout chain returns it, and the order to fix it.

Lin Zhou Reviewed by Emma Collins Also called 504 Gateway Timeout Last updated Nov 28, 2026 Glossary

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:

CodeRFC 9110 meaningWho generated itTypical causeFirst check
500 Internal Server ErrorServer hit an unexpected conditionThe application itselfUnhandled exception, bad code pathApplication error log and stack trace
502 Bad GatewayGateway got an invalid response from upstreamProxy or load balancerApp crashed, closed the connection or returned garbageIs the app process running? Proxy error log
503 Service UnavailableServer temporarily unable to handle the request (overload or maintenance)App, proxy or platformOverload, maintenance mode, no healthy backendsCapacity, maintenance flags, Retry-After
504 Gateway TimeoutGateway did not get a timely response from upstreamProxy or load balancerSlow query, slow outside API, exhausted workersProxy 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.

ScenarioApp needsWhat happensWho answers the browser
A: normal day45 sApp replies inside both timeoutsApp, 200 OK after 45 s
B: slow query75 snginx stops waiting at 60 s and returns 504; the app keeps working until 75 snginx, 504 after 60 s
C: nginx raised to 90 s75 sApp replies at 75 s, inside 90 s and 100 sApp, 200 OK after 75 s
D: nginx at 150 s, query 120 s120 sCDN stops waiting at 100 s, before nginx or the appCDN, its own timeout error after 100 s

Three rules come out of this table:

  1. Each outer timeout should be longer than the inner one. In scenario D the CDN's shorter limit makes nginx's 150 seconds useless.
  2. 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.
  3. 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.

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.

  1. 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.
  2. 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.
  3. An alert on the drop. In All-platform analytics › Operations › Monitors, a monitor on pv or sessions checked hourly can notify you when traffic falls sharply. It only notifies; it does not restart anything.
  4. 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

Was this explanation clear?

We use your answers to fix and expand this page.

Lin Zhou

Product Experience Specialist

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

FAQ

Questions people ask

Short answers to the follow-up questions that come up most.

Still have a question?

Chat with the team behind TapCub — we usually reply within a few hours on business days.

What does a 504 error mean?

It means a gateway or proxy server, such as a CDN, load balancer or nginx, waited for a response from the server behind it and gave up before one arrived. The proxy writes the error page; the application behind it may still be working on the request.

Is a 504 error my fault as a visitor?

Almost never. A 504 is a server-side timeout, so clearing your cache or switching browsers rarely helps. Wait a minute and reload; if it persists, the site owner has to fix a slow application, database or outside service behind the proxy.

What is the difference between a 502 and a 504 error?

Both come from a gateway or proxy. A 502 Bad Gateway means the upstream server answered with something invalid or dropped the connection; a 504 Gateway Timeout means it did not answer within the proxy's timeout. A 502 points at a crashed or misbehaving app, a 504 at slow work.

Does a 504 error hurt SEO?

Briefly, not much. Google says 5xx responses make its crawlers slow down temporarily, and indexed URLs are kept at first. If important URLs keep returning server errors, they are eventually dropped from the index, so persistent 504s need fixing quickly.

See this number on your own site

Add one script tag for web and apps, and the first reports fill in within minutes.

See your data clearly. Find your growth.

Every click, backed by data. Install one line of code and see your first numbers in a minute.

No credit card · Free plans for analytics and chat · Cookieless analytics