What a 504 Gateway Timeout error means
A 504 means the server at the front waited for the server behind it and gave up. Your site is reachable, but something inside it is too slow.
Common causes
- A slow database query, often on a page that lists or searches a lot of data.
- The application is overloaded and requests are queuing.
- A page waits on another service, such as a payment or shipping provider, that is slow to answer.
- A long task, such as an export or an import, runs inside a normal page request.
- A network problem between the front server and the one behind it.
What to check first
- Does every page time out, or only some? One slow page points at that page's code or query.
- Look at the load on the server and the database at the time of the errors.
- Read the application's log for requests that took many seconds.
- Move long tasks out of page requests and into background jobs.
Raising the timeout on the front server hides the error but leaves visitors waiting. Find what is slow first.
Slow before it fails
A site rarely goes straight from fast to timing out. It gets slower first. KeenCrow records the response time of every check and warns you when a site that still answers has become consistently slow, which is often your notice before the 504 errors start.