home / website errors / 504-gateway-timeout

[ REPAIR GUIDE ] WEBSITE ERRORS

How to fix 504 Gateway Timeout

ERROR DETECTED >504 Gateway Timeout

UPDATED NOVEMBER 20263 MIN READ8 FIXES

QUICK FIX

As a visitor, wait a minute and reload, then try another network if it keeps happening. As a site owner, find what is making the origin server slow, such as a long-running script, a slow database query or a server at full capacity.

What it means

A 504 Gateway Timeout means a server in the middle, such as a proxy, load balancer or CDN, waited for the website's main server and gave up because no answer came in time. The main server is usually overloaded, stuck on a slow task or unreachable. It is almost always the website's problem, though a visitor's own network or proxy can occasionally cause it.

Common causes

  • The website's main server is overloaded or very slow
  • A slow script, report, import or database query
  • The main server is down or unreachable from the proxy or CDN
  • Timeout settings between the proxy and the app are too short
  • A firewall blocking traffic between the CDN and the server
  • Less often, a problem with the visitor's proxy, VPN or DNS

How to fix it

Work down the list. Each fix is safe to try before moving on to the next.

FIX 01Wait and reload the pageEASY

  1. Wait about a minute.
  2. Press F5 on Windows or Command + R on a Mac.
  3. If you were placing an order or payment, check your email or account before trying again to avoid a duplicate.

Why it helps: Many 504 errors come from a short traffic spike or a server restart.

FIX 02Try another network or deviceEASY

  1. Open the page on your phone using mobile data instead of Wi-Fi.
  2. If it works there, restart your router and try again on Wi-Fi.
  3. If it fails everywhere, the problem is on the website's side.

Why it helps: If only you are affected, the cause may be your network path rather than the site.

FIX 03Turn off VPN or proxy temporarilyMEDIUM

  1. Disconnect any VPN app.
  2. On Windows 11, check Settings > Network & internet > Proxy and turn off any manual proxy you did not set up on purpose.
  3. On a Mac, check System Settings > Network, select your connection, click Details, then Proxies.
  4. Reload the page, then reconnect your VPN when done.

Why it helps: A slow or broken proxy or VPN server can itself time out and return a 504.

FIX 04Check status and contact the siteEASY

  1. Look for the company's official status page or social media posts about an outage.
  2. If there is nothing, contact the site's support with the page address and the time of the error.

Why it helps: Only the site owner can speed up or repair their server.

// RUN THIS SITE? FIXES FOR SITE OWNERS

FIX 05Check the origin server's healthMEDIUMSITE OWNERS

  1. Open your hosting control panel and check CPU, memory and process usage at the time of the errors.
  2. Read the web server and PHP error logs for timeouts, crashes or workers being killed.
  3. Restart PHP-FPM, the application or the web server if your host allows it.
  4. Ask your host whether the server had an outage or network problem.

Why it helps: A 504 means your origin did not respond in time, so start by checking whether it was overloaded or down.

FIX 06Find and fix slow requestsMEDIUMSITE OWNERS

  1. Note which pages time out; if it is only one page or action, focus on its code.
  2. On WordPress, temporarily disable plugins by renaming wp-content/plugins, then re-enable them one at a time.
  3. Look for slow database queries, large imports or exports, and calls to outside APIs that hang.
  4. Turn on page and object caching so common pages do not need heavy work on every visit.

Why it helps: Making the slow part faster removes the timeout instead of hiding it.

FIX 07Review timeout settingsADVANCEDSITE OWNERS

  1. Back up configuration files before editing them.
  2. On Nginx in front of PHP, check fastcgi_read_timeout; in front of another app, check proxy_read_timeout.
  3. Check PHP's max_execution_time in your control panel's PHP settings.
  4. Raise limits only for tasks that are expected to be long, and move very long jobs to background processing instead.

Why it helps: If a legitimate task needs more time than the proxy allows, the proxy gives up and returns 504.

FIX 08Check Cloudflare or your CDNADVANCEDSITE OWNERS

  1. On Cloudflare, a Cloudflare-branded 504 page means the 504 came from your origin server; fix the origin or contact your host.
  2. A blank 504 page without Cloudflare branding comes from Cloudflare itself; Cloudflare says this can be caused by broken compression from your origin, so test with compression turned off on your server.
  3. Make sure your server firewall allows Cloudflare's IP ranges.
  4. If you contact Cloudflare support, include the time and timezone, the URL and the output of yourdomain.com/cdn-cgi/trace.

Why it helps: The style of the error page tells you whether to look at your server or the CDN.

Check it's fixed

  • The page loads without delay on several tries.
  • The page works from mobile data and Wi-Fi.
  • No new timeout entries appear in your server logs.

When to get help

If your server is regularly maxed out or the logs show nothing, contact your hosting provider with the time of the errors. Visitors should contact the site if it lasts more than a few hours.

Questions

What is the difference between 502 and 504?

With a 502 the gateway got an invalid response from the main server. With a 504 it got no response at all before its time limit.

Is a 504 error my internet's fault?

Usually not. If other sites work and the error also appears on another network, the problem is on the website's side.

Should I just raise the timeout?

Only if the slow task is expected. Raising timeouts on a struggling server hides the real problem and can make overloads worse.

Related fixes

Still stuck?

Paste the exact message and the repair bot will find the closest fix, or search it on Google, Microsoft, Apple, Reddit and YouTube.

Sources