Origin application
- Typical cause
- A slow query, a long job inside a web request, an overloaded server
- Who can fix it
- Site owner or developer
A 504 Gateway Timeout means a proxy or CDN waited too long for the server behind it. See who causes it and how to fix it in nginx, Apache and CDNs.
A 504 Gateway Timeout means a server acting as a gateway or proxy, such as nginx or a CDN, did not get a response in time from the upstream server it needed. The slow or unreachable part is behind the proxy, not your device. Visitors can retry; owners should find what is slow or blocked between the proxy and the origin.
Four quick questions, then a straight answer.
From your answers, this is quietly costing you traffic and nobody has the hours to chase it. Scaplet finds every affected page, drafts the fixes and tracks how AI answers mention you.
A data platform shipped 46 fixes without a ticket.
This looks handled. Re-check after a redesign, a migration or a big content push; that is when it breaks.
Your site is small and you have the time. Work through the steps on this page, starting with the pages that get the most traffic.
If the origin is slow because of a traffic spike or a long task, a retry a little later may work. MDN says the site "may work again at a later time".
MDN names client networking errors as the exception, particularly if the service works for other visitors and if clients use VPNs or other custom networking setups. Try another network or turn the VPN off.
A 504 does not tell you whether the origin finished the work after the proxy stopped waiting. Check your account or email for the result before submitting again.
proxy_read_timeoutfastcgi_read_timeoutproxy_connect_timeoutProxyTimeout in mod_proxyTimeoutcurl -sS -o /dev/null -w "dns %{time_namelookup}s connect %{time_connect}s tls %{time_appconnect}s first byte %{time_starttransfer}s total %{time_total}s\n" https://origin.example.com/slow-pagelocation /reports/ {
proxy_pass http://127.0.0.1:8000;
proxy_read_timeout 120s; # default is 60s
}Raising a timeout is a patch. CloudFront's documentation says "Server timeouts are often the result of either an application taking a very long time to respond, or a timeout value that is set too low", and recommends addressing performance and latency issues before raising its timeout. For a job that legitimately runs for minutes, Cloudflare suggests status polling: return 202 Accepted right away, finish the job in the background, and let the client check for the result.
For CloudFront, check these first, as AWS lists them: a firewall or security group that blocks CloudFront traffic, a custom origin that is not reachable on the internet (private servers and internal Classic Load Balancers cannot be origins), then slow application responses. Test reachability with nc -zv origin.example.com 443.
Causes and fixes differ by server and platform. See the 504 guides for nginx.
Related errors: Apache, IIS, API Gateway, Netlify functions, Vercel functions.
4 questions people ask next, answered from the sources on this page.
Find out whether the origin is slow or unreachable. Time a direct request to it. If it is slow, fix the query or job and only then raise the proxy timeout. If it cannot be reached, check firewalls, security groups and DNS between the proxy and the origin.
Usually not. The proxy waited for an upstream server and did not get a response in time. The exception is your own network: MDN says VPN, firewall, proxy and DNS settings can cause it when the site works for other visitors.
Not necessarily. The proxy is answering, but a server behind it is slow or unreachable. Other pages that do not depend on that server may still work, and the site may work again later.
A 504 is the gateway telling you the upstream server was too slow to answer it. A 408 is a server telling a client that it did not receive a complete request in time. See 408 Request Timeout.
Run the free audit, then approve the fixes. Every change can be undone.