The server you reached passed the request on to the application behind it and gave up waiting for the answer — after 60 seconds by default in nginx. The application is too slow: a long script, a slow database query, a call to another service that hangs, or a server too loaded to keep up.
504 Gateway Time-out nginx
How 3 other clients word the same error
Apache
Gateway Timeout The gateway did not receive a timely response from the upstream server or application.
Cloudflare
Gateway time-out Error code 504
curl -I
HTTP/2 504
| Error | 504 Gateway Timeout |
| Usually fixed by | The site owner or host |
| Status | 504 (RFC 9110 §15.6.5) |
| nginx waits | 60 seconds by default (fastcgi_read_timeout, proxy_read_timeout) |
| Cloudflare waits | 125 seconds — then it shows its own 524 |
Check the site from outside
Enter the address: we load it from our network and show the status code, how long it took, and the error if it failed.
What it means
A gateway or proxy waits a set time for the application’s answer. A 504 means that time ran out. The application may still finish — an import or an order may complete — but the visitor never sees the result.
Apache’s mod_proxy usually reports the same situation as a 502 Proxy Error (“Error reading from remote server”), so an Apache site with a slow backend may show 502 rather than 504.
Why it happens
- A slow request: an import, export, report or backup run from the browser.
- A slow database query, or a table locked by another one.
- A call to an outside service (a payment provider, an API) that does not answer.
- A server so loaded that every request is slow.
What the error log says
nginx
upstream timed out (110: Connection timed out) while reading response header from upstream
How to fix it
- Find the slow part: PHP-FPM’s slow log, the database’s slow query log, or timing the page directly.
- Move long work out of the web request — to cron or a queue — and let the page check for the result.
- Raising nginx’s read timeout only helps together with PHP’s max_execution_time; fixing the slow part is better.
- Give outside calls their own short timeouts, so one slow service cannot hold the page.
If you are visiting the site
- Nothing on your side causes it. Before resubmitting a form or a payment, check whether it went through: the server may have finished the work.
See it for yourself
curl -s -o /dev/null -w '%{http_code} after %{time_total}s\n' https://example.com/slow-page
Shows the status and how long it took — a 504 at exactly 60 seconds is nginx’s default timeout.
Sources
Error text and meaning checked on 25 September 2026 against these official sources:
- RFC 9110: HTTP Semantics — rfc-editor.org
- nginx/src/http/ngx_http_upstream.c at master — github.com
- Module ngx_http_fastcgi_module — nginx.org
- httpd/modules/proxy/mod_proxy_http.c at 2.4.x — github.com
- Connection limits — developers.cloudflare.com