DevToolPal
EN
5xx Server errors

504 Gateway Timeout

What it means

A gateway or proxy did not receive a timely response from the upstream server.

Common causes

  • Slow database queries or external API calls
  • Proxy timeout shorter than processing time
  • Upstream server unreachable due to network issues

How to fix it

As a client or visitor

Retry later; for long operations, ask whether the API offers asynchronous processing.

As the site or API owner

Speed up the slow path or move it to a background job; raise proxy timeouts (proxy_read_timeout) only to realistic values.

Example response

HTTP/1.1
HTTP/1.1 504 Gateway Timeout
Date: Tue, 07 Oct 2025 09:30:00 GMT
Server: nginx
Content-Length: 0

Specification

RFC 9110 §15.6.5

FAQ

› How do I fix 504 Gateway Timeout in nginx?

Find why the upstream is slow; if long requests are expected, raise proxy_read_timeout and the app server's timeout together.

› Who returns 504, my app or the proxy?

The proxy, load balancer or CDN in front of your app, after waiting too long for it.