According to DEV Community, a WordPress 504 gateway timeout means a gateway or proxy timed out while connecting to an upstream server, sending it a request, or waiting for its reply. A 502 means the upstream gave an invalid response. The article says the status code only tells you where to start looking, not what caused the problem.
The guide advises recording one failing request with an exact timestamp and timezone, then following that request through the edge or CDN, the web proxy and the PHP logs. It says not to restart PHP, purge caches, disable plugins or change timeouts first, because that can erase the evidence.
For Nginx with PHP-FPM, the article explains that the error log wording shows which stage timed out: connecting, sending the request, or reading the response header. The last two prove a connection existed, but not that a PHP worker had started the request. A connection can wait in a queue while all workers are busy.
The article also covers a 502 on Linux with a Unix socket. A message of Resource temporarily unavailable can point to a full queue and FPM capacity pressure rather than a stopped service. It warns that PHP-FPM's status page does not report queue length for Unix-socket listeners, so the article suggests checking the socket directly with ss -xlp.
Finally, it recommends applying one fix that matches the evidence, then repeating the same safe request and comparing a second timeline. It advises against raising worker counts or timeouts based on a single 504, and against recreating outage-level load on a live site.
Why it matters
A 504 or 502 page is easy to treat as a vague server problem, and the usual reaction is to raise a timeout or restart services. The article argues that this can hide the cause or make it worse, since a longer wait lets a slow request hold capacity for longer.
The guide gives site owners and developers a repeatable way to work with a host or developer. A single timestamped request, matched across logs, shows whether the fault is a down service, a saturated PHP worker pool, a slow page or a proxy issue.
Source: DEV Community. This brief summarises their reporting; read the original for the full detail.