AES Encryption Explained: How It Works and Why It Matters
Jun 23, 2026
5xx Server Error
The 504 (Gateway Timeout) status code indicates that the server, while acting as a gateway or proxy, did not receive a timely response from an upstream server. Unlike 502 (Bad Gateway) which indicates an invalid response, 504 specifically means the upstream server did not respond within the timeout period.
When Nginx is configured with a 60-second timeout and the PHP-FPM process is stuck on a slow database query exceeding that limit, Nginx returns 504 Gateway Timeout. Identify and optimize slow queries, increase timeout values, or implement query caching to resolve this.
# Nginx - increase proxy timeout for slow endpoints
location /api/reports {
proxy_read_timeout 120s;
proxy_connect_timeout 30s;
proxy_pass http://backend;
}
# Laravel - increase PHP execution time for long requests
set_time_limit(120);
Mistake: Confusing 504 (timeout) with 502 (bad response)
Fix: 504 means the upstream server did not respond within the timeout period. 502 means it responded but with an invalid or empty response. Check upstream logs to distinguish between the two.
Mistake: Simply increasing timeouts instead of fixing root causes
Fix: While increasing timeouts can resolve 504 errors temporarily, identify and fix the root cause — slow queries, external API latency, or resource contention. Infinite timeouts can mask serious performance issues.
Blog
Jun 23, 2026
Jun 23, 2026
Jun 23, 2026
Jun 23, 2026
Jun 23, 2026
Jun 23, 2026