Opens in a new tab

504 Gateway Timeout: the application took too long

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
Error504 Gateway Timeout
Usually fixed byThe site owner or host
Status504 (RFC 9110 §15.6.5)
nginx waits60 seconds by default (fastcgi_read_timeout, proxy_read_timeout)
Cloudflare waits125 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

  1. Find the slow part: PHP-FPM’s slow log, the database’s slow query log, or timing the page directly.
  2. Move long work out of the web request — to cron or a queue — and let the page check for the result.
  3. Raising nginx’s read timeout only helps together with PHP’s max_execution_time; fixing the slow part is better.
  4. 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:

Know when your site goes down — before your visitors do

Add your site and we check it every few minutes, confirm a failure from another location — Europe, North America or Asia — before calling it down, and email you when it stops answering and when it is back. Free for two sites.

Create a free account