504 Gateway Timeout

How to Fix “504 Gateway Timeout”

HTTP Status Error 📄 All browsers
⚡ Quick answer

A 504 Gateway Timeout means a server acting as a gateway (like Nginx or Cloudflare) waited too long for a response from an upstream server and gave up. The upstream server is too slow or unresponsive.

First, check if your internet is working and what your current IP address is:

🔍 Check My IP Address →

What Causes the “504 Gateway Timeout” Error?

Like 502, a 504 occurs at the gateway level — but instead of an invalid response, the gateway timed out waiting for any response. The upstream server accepted the connection but took too long to process the request. Common causes: a slow database query locking up the application, an upstream API your site depends on being slow, server overload, a long-running PHP or Python script exceeding timeout limits, or misconfigured timeout settings on the gateway.

How to Fix It — 5 Methods

1 Reload and retry after waiting
  1. Press Ctrl+F5 and wait 30–60 seconds
  2. 504 errors from temporary overload often resolve themselves
  3. Try at a different time of day if the site is consistently slow
2 Clear browser cache and DNS
  1. Press Ctrl+Shift+Delete → clear all → reload
  2. Also run ipconfig /flushdns in Command Prompt
3 Try a different DNS

Switch to Google DNS (8.8.8.8) or Cloudflare (1.1.1.1). DNS delays can make a slow server appear to timeout even faster.

4 If you own the site — identify the slow query or process
  1. Check your slow query log in MySQL/MariaDB
  2. Use New Relic, Datadog, or your hosting's APM to find the slow transaction
  3. Increase PHP max_execution_time in php.ini: max_execution_time = 300
  4. Increase Nginx proxy timeout: proxy_read_timeout 300s;
5 Use a CDN to buffer slow back-end responses

A CDN like Cloudflare caches responses and serves cached content even when the back-end is slow, preventing 504s from reaching end users.

  1. Enable Cloudflare's caching rules for your site
  2. Set cache TTL for static and semi-static pages
🔒
Some errors are caused by ISP blocks or network restrictions
A VPN bypasses them instantly by routing through a different server.

Fixed it? Visit tools.examineip.com to confirm your IP address and connection are working correctly.

Frequently Asked Questions

What is the difference between 502 and 504?
502 means the gateway received a bad/invalid response. 504 means the gateway gave up waiting — the upstream never responded in time. Both indicate back-end server problems.
Is a 504 error always the server's fault?
Yes. 504 is a server-side error. As a visitor there is nothing you can do except wait and retry.
Can Cloudflare cause a 504?
Yes. If your origin server is too slow to respond within Cloudflare's timeout window (default 100 seconds), Cloudflare returns a 504. Increase the timeout in Cloudflare's settings or fix the slow server process.

Learn More About IP Addresses & Privacy

Other Internet Errors Explained

← Back to the complete guide: Internet Errors Hub

Last updated: March 30, 2026 • Report an error

Scroll to Top