← Back to all fixes

Nginx 504 Gateway Timeout

The Issue

Some requests return 504 Gateway Timeout after 60 seconds.

Root Cause

The upstream app is taking longer than nginx's `proxy_read_timeout` (default 60s) to respond.

How to Fix
  1. Increase timeout in nginx config: `proxy_read_timeout 120s;` inside the location block
  2. Also set: `proxy_connect_timeout 60s;` and `proxy_send_timeout 60s;`
  3. Reload nginx: `sudo systemctl reload nginx`
  4. Investigate why the app is slow — the timeout is a workaround, not a fix
  5. Add request tracing to find slow database queries or external API calls