A 504 Gateway Timeout happens when one server fails to receive a timely response from another server acting as an upstream provider. This error typically occurs during communication between a proxy server like Nginx or a CDN like Cloudflare and your origin server. It indicates the primary server is taking too long to process the request or is completely unresponsive.
Technical causes often involve PHP scripts hitting their maximum execution time or database queries stalling performance. When your PHP-FPM workers reach their limit, the system queues new requests until they time out. Resource exhaustion including CPU spikes and memory limits also triggers this status code.