This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

How to Fix the 504 Bad Gateway Timeout Error

Updated on June 23, 2022

3 Min Read
fix 504 gateway timeout error in wordpress

Besides 500 and 503, 504 is one of the most common HTTP errors you can run into. As we mentioned in other articles, errors from the 500 family are the hardest to understand since the error pages are generic and don’t give you many clues about the culprit.

What Is the 504 Gateway Timeout Error?

A 504 error basically means that one of the servers in the network didn’t respond in the expected time, and the request sent by your browser was not returned.

Here’s what the error page might look like on your browser:

  • Error 504
  • HTTP Error 504
  • HTTP Error 504 — Gateway Timeout
  • HTTP 504
  • Gateway Timeout Error
  • 504 Error
  • Gateway Timeout (504)
  • 504 Gateway Timeout
  • 504 Gateway Timeout NGINX
  • NGINX 504 Gateway Timeout
  • 504 Gateway Timeout

Why Does 504 Gateway Timeout Error Occur?

The 504 error usually occurs when the main server doesn’t get a timely response from the upstream server and times out. You may see it pop up if you’re using Cloudflare – say Cloudflare sends a request to your server and it doesn’t respond in time. In that case, Cloudflare returns the error 504 to your browser.

The issue might be down to a component in the hosting infrastructure, like the database or reverse proxy that fails to respond in time. That can cause your browser to display error 504.

Fix the 504 Gateway Timeout Error in WordPress

The 504 error could have any number of causes behind it, which is why you’ll have to try out a few troubleshooting methods in turn and see what sticks. Let’s start from the client-side.

  1. Try refreshing the browser or visiting the same URL in incognito mode.
  2. Reset your router.
  3. Check your proxy settings, and make sure it’s turned to auto-detect settings.

Debugging on the Server-side to Fix Error 504

If none of the client-side advice helped, you need to dive deeper into potential server issues to find the cause and debug.

  1. First, check the error log to see if some of the themes or plugins are wasting memory space and causing this issue. This isn’t a common cause, but it’s possible for a malfunctioning plugin to slow down the server so it cannot respond in the expected time.
  2. If step 1 doesn’t help, deactivate your CDN if you’re using one.
  3. Use a DNS Checker like whatsmydns to see if the FQDN (fully qualified domain name) resolves to the correct IP address. Flush your DNS cache.
  4. Check with your hosting provider – perhaps it’s an issue on their end – and resolve it together with them.

To make your life much easier, we have integrated Cloudflare into our infrastructure, which you can activate in the following steps.

In your application settings, click on the Cloudflare option and insert the domain name used for that application.

cloudflare option in cloudways

After enabling Cloudflare for your application, add the TXT records to confirm domain ownership. Set up these values where your DNS is handled; this is usually the place where you’ve bought the domain.

verify domain ownership

After you create these two records it will take some time for Cloudflare to confirm your domain. As soon as it’s done, create an A/CNAME record to point DNS to Cloudflare and complete activation.


Server errors can be caused by a faulty plugin or a theme, even corrupted WordPress core. However, that is not the case with 504 Gateway Timeout since it’s pointing out that the communication between two servers is not established or one of the servers didn’t respond.

Avoid losing time looking for the culprit in WordPress because that would be the last place to look.

We hope this article helped in resolving this issue and feel free to contact our support team if you ever experience it with us.

Share your opinion in the comment section. COMMENT NOW

Share This Article

Customer Review at

“Beautifully optimized hosting for WordPress and Magento”

Arda Burak [Agency Owner]

Aleksandar Savkovic

WordPress Developer, Lecturer, the product guy interested in Agile product development. WordCamp and WP/Woo Meetup speaker and Organizer, and Community Manager at Cloudways. Also, a Formula 1 and MotoGP freak.


Get Our Newsletter
Be the first to get the latest updates and tutorials.

Thankyou for Subscribing Us!


Webinar: How to Get 100% Scores on Core Web Vitals

Join Joe Williams & Aleksandar Savkovic on 29th of March, 2021.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!