Troubleshoot 504 errors

❗

Gateway timeout.

A 504 Gateway Timeout means PHP did not answer in time. Slow requests occupy the PHP processes, new requests queue up behind them, and the page loads for a long time before the error. It often comes together with 503 errors.

How a 504 shows

  • The page loads for a long time before the error appears.
  • The errors come and go, often with traffic peaks or after an editor's action in a CMS.
  • They appear without a deployment. See performance problems are often people problems.
  • The PHP log stays empty: a request that times out ends before it can write an error.

Find the slow requests

The metrics of the environment show the PHP response time and the HTTP errors per hour. A 504 spike sits on top of a rising response time. The access log in the logs shows which paths were requested at that time; paths that repeat often are the first suspects.

Common causes

CauseRead
Slow or too many database queriesDatabase performance
Image transforms on upload or first viewImage transforms
An external API that answers lateSet a short timeout in the HTTP client
Bots crawling endless filter or search URLsBlock IPs, incoming firewall
Plugins, loops, templates that include themselvesCommon issues

A profiler such as Blackfire shows where a slow request spends its time. Full-page caching, in the app or in a CDN such as Cloudflare, takes most requests off PHP.

Timeouts

max_execution_time in the PHP settings ends a PHP script after the set number of seconds. A low value frees the PHP process sooner, so one slow request blocks fewer others. See PHP processes.

Platform status

When the metrics show no slow requests, check the fortrabbit status page for incidents.

Written by a human. Review, grammar checks and typo fixes by AI.

AI use & editorial processEdit on GitHub ↗