What it means
A 504 involves two servers: a proxy, CDN or load balancer receives the request and forwards it to the backend, which doesn't respond within the timeout. With a 502 the backend response is invalid; with a 504 it doesn't arrive in time at all.
Most common causes
- A slow database query or long-running task.
- An overloaded backend server.
- A proxy timeout set too low (proxy_read_timeout).
- A network problem or firewall between the proxy and the backend.
- Backend DNS not pointing at the right server.
What you can do as a visitor
- Refresh the page after a minute or two.
- Check whether the site works for others.
- If it's your own router or a local proxy, restart it.
What the site owner or developer should do
- Search the proxy and backend logs for requests that exceed the timeout.
- Optimise slow queries and move long tasks to the background (job queues).
- If needed, increase proxy timeouts moderately.
- Make sure the backend accepts connections from the proxy's IPs.
Impact on SEO and Google
Occasional 504s do no harm. Recurring 504s point to a slow backend, which slows crawling and hurts the user experience.
Frequently asked questions
What's the difference between 502 and 504?
502: the backend returned an invalid response. 504: the backend didn't respond in time.
Is a 504 caused by my internet connection?
Almost never. The problem is between the website's servers.