How to Fix the 504 Gateway Timeout Error in WordPress

Featured image: How to Fix the 504 Gateway Timeout Error in WordPress

A 504 Gateway Timeout error in WordPress means one server waited for another and gave up. Visitors see a blank error page, and search engines see a failing site. The good news is that the cause is usually one of a few things, and you can check them in order.

This guide explains what the error means, then walks through eight checks from the quickest to the most technical. You will also see where the usual timeout limits come from.

TL;DR

A 504 means a gateway or proxy did not get a response from the upstream server in time. On WordPress sites the usual causes are a slow plugin, a heavy database query, a low PHP time limit, a proxy timeout, or a busy host. Test for a temporary problem first, then switch off plugins, check limits, and talk to your host.

⚡ Key Takeaways

  • A 504 error comes from a gateway or proxy that did not receive a response from the origin in time.
  • It is different from a 502, where the gateway received a bad response.
  • Nginx waits 60 seconds by default between two reads from the proxied server (proxy_read_timeout).
  • PHP stops a script after 30 seconds by default (max_execution_time), except on the command line.
  • Start with the easy checks: retry, plugins, then limits, then hosting.

What Is a 504 Error (Gateway Timeout)?

According to MDN, the HTTP 504 status code means a server acting as a gateway or proxy did not get a response in time from the upstream server. MDN adds that it is similar to a 502 Bad Gateway, except that in a 504 the gateway received no HTTP response from the origin within a certain time.

On a WordPress site, the gateway is often a web server or a CDN. The origin is the server that runs PHP and the database. If WordPress takes too long to build the page, the gateway stops waiting and shows the error.

Checklist of eight steps to fix a 504 gateway timeout error in WordPress, from retrying the page to checking hosting resources
Eight checks, from the quickest to the most technical.

MDN also notes that fixing these problems often needs investigation by server administrators. Some errors disappear on their own, and some are caused by the visitor’s own network.

Step 1: Check That the 504 Error Is Not Temporary

First, reload the page after a minute. Then open the site on another device or network. If it loads there, the problem may be local, such as a VPN, a proxy or your DNS settings.

Next, test other pages and the admin area. If only one page fails, look at what that page does. If everything fails, the problem is more likely the server or the host.

Step 2: Switch Off Plugins and Test the Theme

A slow or broken plugin is a common cause. Deactivate all plugins from the dashboard, or rename the plugins folder over FTP if you cannot log in. Then test the site.

If the error goes away, turn the plugins back on one by one until it returns. Also, try a default theme. These tests show whether the delay comes from your code or from the server.

Step 3: Check the PHP Time Limit

PHP stops a script that runs too long. According to the PHP manual, max_execution_time sets the maximum time in seconds that a script may run, and the default is 30. When PHP runs from the command line, the default is 0.

However, if a task needs longer, such as a big import, you can raise the limit in your host’s PHP settings. Raise it only as far as needed. A very high limit can hide a slow query instead of fixing it.

Step 4: Look at Nginx and Proxy Timeouts

If your host uses Nginx as a reverse proxy, it has its own limits. The Nginx documentation says proxy_read_timeout defaults to 60 seconds. The timeout applies between two successive read operations, not to the whole response. If the proxied server sends nothing within that time, Nginx closes the connection.

The same documentation says proxy_connect_timeout also defaults to 60 seconds. Managed hosts usually set these values for you. So, ask support before you change them.

Step 5: Clean and Check the Database

Slow database queries make pages slow, and slow pages hit timeouts. Remove old revisions, spam comments and expired transients. A database tool from your host or a trusted plugin can do this.

Take a backup first. After that, check whether one plugin runs the same heavy query on every page.

Step 6: Review Your CDN and Firewall

A CDN or firewall also acts as a gateway. If the origin is slow, the CDN may time out first. Check your CDN dashboard for origin errors, and make sure your server is not blocking the CDN’s requests.

For example, pause the CDN for a short time and load the site directly. If the error disappears, the CDN settings or the connection to the origin need attention.

Step 7: Check Hosting Resources

Shared hosting can run out of CPU, memory or process slots during a traffic peak. When that happens, requests queue up and time out. Look at the resource graphs in your hosting panel.

If you see regular spikes, you can move to a bigger plan, or add page caching so that WordPress builds fewer pages. A step-by-step routine for other speed problems is in this WordPress performance checklist.

Step 8: Ask Your Host and Turn On Logs

If the steps above do not help, contact your host. Ask them to check the web server and PHP error logs for the time of the error. As a result, those logs usually show whether the request timed out in PHP, in the database or at the proxy.

The same order of checks works for HTTP error 500 in WordPress.

Does a 504 Error Hurt SEO?

A short outage is rarely a lasting problem. However, a server that keeps failing is another matter, because search engines cannot read your pages. Fix repeat errors quickly, and watch the Crawl stats and Pages reports in Search Console for spikes in server errors.

Regular updates, backups and monitoring prevent many of these cases, and they fall under WordPress support and maintenance.

Worked Example of a 504 Error (Made-Up)

Here is an invented case. A shop gets a 504 on its checkout page only. The owner turns off plugins one by one and finds that a shipping plugin makes a slow request to an outside service. The request often takes more than 60 seconds.

The owner replaces the plugin with a lighter one and turns on page caching for other pages. As a result, the error stops. This example is made up. It shows why testing one change at a time beats guessing.

504 Error Checklist

  1. Reload, then test from another device or network.
  2. Deactivate plugins and try a default theme.
  3. Check the PHP max_execution_time value (default 30 seconds).
  4. Ask your host about Nginx proxy timeouts (default 60 seconds).
  5. Clean the database after taking a backup.
  6. Pause the CDN briefly to test the origin.
  7. Check CPU and memory graphs for spikes.
  8. Read the server and PHP logs, or ask your host to.

Conclusion

A 504 error looks scary, but it follows a clear pattern: something took too long. So, work through the checks in order, change one thing at a time, and keep notes. Most cases end with a plugin fix, a limit change or a hosting upgrade.

Finally, once the site is stable, set up monitoring so that you hear about timeouts before your visitors do.

Frequently Asked Questions About the 504 Error

What does a 504 error mean?

It means a server acting as a gateway or proxy did not get a response from the upstream server in time. The origin server may be slow, overloaded or unreachable.

What is the difference between 502 and 504?

MDN explains that a 504 is similar to a 502, but with a 504 the gateway received no HTTP response from the origin within a certain time. With a 502, the gateway received an invalid response.

How long does Nginx wait before a 504?

By default, proxy_read_timeout is 60 seconds, measured between two successive reads from the proxied server. Your host may have changed it.

Can a plugin cause a 504 error?

Yes. A plugin that runs slow queries or waits on an outside service can push a page past the timeout. Deactivating plugins is a quick test.

Should I increase the PHP time limit?

Only if a task truly needs more time. The PHP default is 30 seconds. A higher limit can hide a slow query instead of fixing it.

Sources

Atul Chaudhary

Atul Chaudhary

With 18 years of industry experience, Atul specializes in building scalable digital products and crafting data-driven marketing strategies that deliver measurable business growth.