LightAtom

504 Gateway Timeout: How to Fix It

A gateway or proxy forwarded your request but the server behind it didn't answer in time, usually because it's overloaded or stuck on a slow task.

504 Gateway Timeout

A server in front of the website (a proxy, CDN or load balancer) waited for the application server to respond and gave up after its timeout.

Quick checks

  • Reload in a minute; slow backends often recover.
  • Check whether the site is down for others.
  • If a specific action (an upload, a report) times out, try something lighter to see if the site itself works.

If you’re visiting the site

  1. Retry later

    1. Wait a minute or two and reload.
    2. If you were submitting a form or payment, check whether it went through before retrying, so you don't do it twice.
  2. Rule out your proxy

    1. Turn off VPNs and proxies; a corporate proxy can return its own 504.

If you run the site

  1. Find the slow request

    1. Check the app's logs and APM for requests that run longer than the proxy timeout.
    2. Slow database queries, external API calls and large exports are the usual culprits.
  2. Match timeouts across layers

    1. nginx: proxy_read_timeout (default 60 s); load balancers and CDNs have their own (Cloudflare's is 100 s).
    2. Raise timeouts only for endpoints that genuinely need it; move long jobs to background workers.
  3. Check capacity

    1. Exhausted worker pools queue requests until they time out. Look at CPU, memory and connection counts during the errors.

Still not working?

A 504 is a server-side issue. If it happens every time for one action, report it to the site with the time and what you were doing.

Owners: reproduce with curl -w '%{time_total}\n' -o /dev/null -s https://example.com/slow-path from inside your network to see the backend's real response time.

See what’s happening

For local development, LightAtom's connections view shows which app holds open connections to a slow backend.

Frequently asked questions

What causes a 504 Gateway Timeout?

The backend server is too slow: overloaded, waiting on a database or an external API, or stuck. The proxy in front gives up when its timeout runs out.

Is 504 a problem with my internet?

No. Your request reached the website's gateway fine; the delay is between the gateway and the site's own servers.

What's the difference between 504 and 408?

408 Request Timeout means the server waited too long for you, the client, to send the request. 504 means the gateway waited too long for the upstream server.

How do I fix 504 in nginx?

Find why the upstream is slow first. If a long request is legitimate, raise proxy_read_timeout for that location, and consider handling the work in the background.

LightAtom team

The people who build LightAtom, a network monitor for macOS.