Toolman

HTTP 504 — Gateway Timeout

5xx Server Error

What it means

A proxy did not get a response from the upstream server in time.

What to do about it

The backend is too slow. Profile the slow endpoint, add a database index, or raise the proxy timeout — but a timeout is a symptom, and raising it usually just moves the problem.

Where it sits

504 belongs to the 5xx family: The server failed to fulfil an apparently valid request. The fix is on the server side.

HTTP/1.1 504 Gateway Timeout

Checking it yourself

# see the status code and headers only
curl -sI https://example.com/path

# follow redirects and print each hop
curl -sIL -o /dev/null -w "%{http_code} %{url_effective}\n" https://example.com/path

# JavaScript
const r = await fetch(url);
console.log(r.status, r.statusText);

How this code behaves

Cacheable by defaultNo — caches must not store this response unless explicit cache headers permit it.
Safe to retryYes, with backoff. This is a transient condition; retrying the same request is reasonable.
Effect on search indexingRepeated server errors reduce crawl rate and eventually drop pages from the index.

Returning 504 correctly

# nginx
return 504;

# Express
res.status(504).json({ error: 'Gateway Timeout' });

# Go
w.WriteHeader(504)

# Python (Flask)
return jsonify(error='Gateway Timeout'), 504;

Frequently asked questions

What does HTTP 504 mean?

A proxy did not get a response from the upstream server in time.

How do I fix a 504 error?

The backend is too slow. Profile the slow endpoint, add a database index, or raise the proxy timeout — but a timeout is a symptom, and raising it usually just moves the problem.

Is 504 a client or server problem?

A server problem. The request was valid; the server failed to fulfil it. Nothing the client changes will help.

Other 5xx codes

All HTTP status codes