Esta página aún no está traducida al español, así que la mostramos en inglés.

HTTP 504 Gateway Timeout

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

Actualizado el

504
Gateway Timeout
5xx Server error
Class
RFC 9110 §15.6.5
Defined in

What does HTTP 504 mean?

A gateway or proxy did not get a response from the upstream server in time. The application is reachable but too slow: the proxy gives up after its timeout (60 s by default in Nginx proxy_read_timeout; 100 s at Cloudflare; 10–60 s on serverless platforms).

5xx Server error: The request looked valid, but the server failed to fulfil it. The fix is on the server side.

Common causes of a 504 error

  • Slow database queries or external API calls.
  • Long-running requests such as reports or imports done synchronously.
  • Serverless function time limits.

How to fix 504 Gateway Timeout

  • Optimize slow queries and add caching.
  • Move long tasks to background jobs and return 202.
  • Raise proxy timeouts only as a last resort.

How to find the cause of a 504

A 504 means your app is too slow for the proxy’s time limit, so time the app directly.

curl -o /dev/null -s -w 'total: %{time_total}s\n' http://127.0.0.1:3000/slow-page
sudo tail -n 30 /var/log/nginx/error.log

If the direct request is slow, fix the slow query or outside call. Raising the limit, such as proxy_read_timeout 120s; in Nginx, only helps for work that is meant to take long. Move long jobs to the background instead.

504 and SEO

Slow responses hurt Core Web Vitals and crawling; persistent 504s cause deindexing like other 5xx errors.

Example response

HTTP/1.1 504 Gateway Timeout

How to return a 504 response

Node.js (Express)

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

PHP

http_response_code(504);

Python (Flask)

return {'error': 'Gateway Timeout'}, 504

Go (net/http)

w.WriteHeader(504)

nginx

return 504;

Related status codes

Check which status code a URL returns with the HTTP header checker.

All HTTP status codesSearch the full list of status codes from 100 to 599 with their meanings and SEO impact.
Open the full list

Preguntas frecuentes

What does status code 504 mean?
504 Gateway Timeout: A gateway or proxy did not get a response from the upstream server in time.
How do I fix a 504 error?
Optimize slow queries and add caching. Move long tasks to background jobs and return 202.
Does 504 affect SEO?
Slow responses hurt Core Web Vitals and crawling; persistent 504s cause deindexing like other 5xx errors.