5xx Server & Gateway Error

HTTP 504 Gateway Timeout — Reverse Proxy & Gateway Troubleshooting

HTTP 504 Gateway Timeout means the reverse proxy or API gateway successfully connected to the upstream server (or tried to connect) but did not receive a timely HTTP response byte within its configured deadline.

Status Code504 Gateway Timeout
Specification / OriginRFC 9110 ยง15.6.5
Failure LayerReverse Proxy Upstream Timer
Retry SafetySafe for idempotent GET/HEAD with exponential backoff + jitter

Interactive HTTP 504 Live Probe & Log Command Builder

Enter your target endpoint below to generate copy-ready curl latency breakdown probes and origin bypass tests:


  

Related diagnostics: Nginx & Caddy Proxy Generator → · X.509 SSL Certificate Decoder → · Offline JWT Expiry Inspector →

Production Root Causes & Remediation Guide

Nginx defaults proxy_read_timeout to 60 seconds, AWS API Gateway enforces a hard 29-second cap, and firewall blackholes dropping SYN packets to unreachable private subnet IPs stall proxy_connect_timeout until expiration.

Step-by-Step Engineering Fix

Optimize slow SQL queries or move long-running report/LLM tasks to async job queues + SSE/WebSocket streaming; if synchronous long calls are mandatory, raise proxy_read_timeout and proxy_send_timeout selectively on that route.

Recommended Nginx / Reverse-Proxy Configuration Snippet

location /api/stream/ {
    proxy_connect_timeout 5s;
    proxy_send_timeout 180s;
    proxy_read_timeout 180s;
    proxy_buffering off;
}

Frequently Asked Questions (HTTP 504)

How do you tell if a 504 timeout happened during TCP connect vs slow execution?

Check Nginx error.log: 'upstream timed out while connecting to upstream' points to a firewall/routing drop, while 'while reading response header' points to slow app code.

Which infrastructure layer generates HTTP 504 Gateway Timeout?

HTTP 504 (RFC 9110 ยง15.6.5) typically originates at the Reverse Proxy Upstream Timer layer. HTTP 504 Gateway Timeout means the reverse proxy or API gateway successfully connected to the upstream server (or tried to connect) but did not receive a timely HTTP response byte within its configured deadline.

Should API clients automatically retry HTTP 504 responses?

HTTP 504 is safe to retry ONLY for idempotent methods (such as GET or HEAD) using exponential backoff with random jitter.

Browse All 25 Gateway, Proxy & Cloud HTTP Error Guides

HTTP 400 (Bad Request) HTTP 401 (Unauthorized) HTTP 403 (Forbidden) HTTP 404 (Not Found) HTTP 405 (Method Not Allowed) HTTP 408 (Request Timeout) HTTP 413 (Content Too Large) HTTP 422 (Unprocessable Content) HTTP 429 (Too Many Requests) HTTP 431 (Request Header Fields Too Large) HTTP 499 (Client Closed Request) HTTP 500 (Internal Server Error) HTTP 501 (Not Implemented) HTTP 502 (Bad Gateway) HTTP 503 (Service Unavailable) HTTP 504 (Gateway Timeout) HTTP 507 (Insufficient Storage) HTTP 511 (Network Authentication Required) HTTP 520 (Web Server Returned an Unknown Error) HTTP 521 (Web Server Is Down) HTTP 522 (Connection Timed Out) HTTP 523 (Origin Is Unreachable) HTTP 524 (A Timeout Occurred) HTTP 525 (SSL Handshake Failed) HTTP 526 (Invalid SSL Certificate)

Copied to clipboard