handy.moe

All tools / Debug tools / Status codes

HTTP 504 Gateway Timeout

A gateway or proxy waited too long for the server behind it.

This page runs in your browser and makes no requests.

504 Gateway Timeout

A gateway or proxy waited too long for the server behind it.

Common causes

A slow database query or upstream call, a proxy timeout lower than the job's run time (nginx proxy_read_timeout defaults to 60 s).

What to do

Speed up the slow step, raise the proxy timeout, or turn the job into a background task that returns 202.

Class: 5xx Server error · Defined in RFC 9110 §15.6.5

How to use it

  1. Look at the response in your browser's Network tab, or run curl -i URL to see the status line and headers.
  2. Read the response body: many servers explain the exact reason there.
  3. Fix the cause above and send the request again.

Questions

Is 504 an error?

Yes: it is a server error. The request was fine; the server (or something behind it) failed.

Should I retry a 504?

Yes, with exponential backoff, because 5xx errors are often temporary. Respect Retry-After if it is sent.

Where can I see the 504 in my browser?

Open the developer tools (F12 or Cmd+Option+I), go to the Network tab, reload, and look at the Status column. Click the request and open the Response and Headers tabs for the details.