~/devtools / http-status / 504
tool::http-status-detail

504 Gateway Timeout

The gateway did not receive a timely response from an upstream server.

ad · 728×90
Status Code
504
Name
Gateway Timeout
Category
5xx

Detailed Explanation

HTTP 504 Gateway Timeout indicates that a gateway or proxy server did not receive a timely response from an upstream server. Unlike 502 (which signals a bad response), 504 means no response arrived at all within the timeout window. It commonly occurs when a slow database query or external API call causes the upstream server to miss the proxy's timeout.

Common Causes
  • The upstream server is delayed by a slow database query
  • The upstream processing time exceeds the proxy's configured timeout
  • The upstream server is overloaded and responding slowly
  • An external API call is blocking the entire request pipeline
  • Network congestion is delaying packet delivery between servers
How to Fix
  • 1.Increase Nginx's proxy_read_timeout and proxy_connect_timeout values
  • 2.Optimize slow database queries (analyze execution plans)
  • 3.Check upstream server load and consider scaling out
  • 4.Apply timeout and circuit-breaker patterns to external API calls
  • 5.Offload long-running tasks to async queues and worker processes

Related HTTP Headers

Retry-AfterServer

Response Example

HTTP/1.1 504 Gateway Timeout
Server: nginx/1.24.0
Content-Type: text/html

<html><body><h1>504 Gateway Timeout</h1><p>The upstream server did not respond in time.</p></body></html>

Related Status Codes

500Internal Server ErrorThe server encountered an unexpected condition.501Not ImplementedThe server does not support the requested functionality.502Bad GatewayThe gateway received an invalid response from an upstream server.503Service UnavailableThe server is temporarily unable to handle the request.505HTTP Version Not SupportedThe HTTP version used in the request is not supported.
ad · 300×250
Back to all status codes
// related tools
Cron Expression Generator
Build and parse cron expressions visually. Generate human-readable descriptions and preview next execution times.
jwt
JWT Decoder
Decode and inspect JWT tokens. View header, payload, and signature details.
rx
Regex Tester
Test regular expressions with live matching, group highlighting, and explanations.
Color Converter
Convert colors between HEX, RGB, HSL, and more. Pick colors visually.