Enter your search term

Search by title or post keyword

How to Fix 502 Bad Gateway Error

Our website is supported by our users. We sometimes earn affiliate links when you click through the affiliate links on our website

Contact us for Questions

502 Bad Gateway error is a common server error that hurts website SEO as much as it does users’ experience.

Left too long, you might lose some potential customers and a bit of brand credibility.

If you’ve noticed that your website returns the 502 bad gateway error when users are trying to access it, you need to act fast.

Don’t worry if you aren’t accustomed to fixing bugs in WordPress like this.

This tutorial will show you how to fix the 502 Bad Gateway error plaguing your website.

Frequently Asked Questions

What is the 502 Bad Gateway Error?

A 502 bad gateway error status code indicates something is wrong with a server communication while acting as a gateway or proxy.

In simpler terms, when accessing a website, your browser sends an HTTP request to the website server but gets an invalid response, thereby returning the 502 bad gateway error.

What Causes a 502 Bad Gateway Error?

The causes of the 502 bad gateway error include an overloaded origin server, firewall overprotection, unresolved domain name, and at times browser error.

Irrespective of the cause, fixing 502 bad gateway errors on your website is simple.

One or a combination of the fixes below should solve it.

What You’ll Need to Fix 502 Bad Gateway Error

  • WordPress Admin Access: If your website is built on WordPress CMS, you can solve 502 bad gateway errors related to your themes and plugins from your WordPress admin dashboard.
  • Hosting Cpanel: You’ll also need access to your hosting account control panel.

How to FIx 502 Bad Gateway error

At times, the problem might not be serious.

502 bad gateway errors could result from a corrupt browser’s cookies, cache data, and even the user’s device.

So before using the troubleshooting methods in this tutorial, try the following basic fixes:

  1. Refresh the Web Page: When you encounter a 502 bad gateway error, the first thing to try is to reload. There may be too much traffic on the site. Wait for a few minutes and try again.
  2. Use Another Browser: You can also try a different browser. That is to be sure the problem is not the browser.
  3. Clear Browser Cache: A corrupt or outdated browser might be responsible if you can access the website on another browser. Clearing your browser cache files should fix it.
  4. Check if the Website Is Down: If you still see 502 bad gateway errors after clearing your browser cache, you need to check if the website is not down.

Two tools you can quickly use to check are Down for Everyone or Just Me and Is It Down Right Now.

Just paste the website URL, and you’ll know if the website is down or if the problem is from your end.

The above basic troubleshooting methods might solve the 502 bad gateway error.

If none of them works, then proceed to the following fixes.

  1. Fix #1: Temporarily Disable Plugins and Themes
  2. Fix #2: Check Your Site Error Log
  3. Fix #3: Restart Increase PHP Timeout Limit
  4. Fix #4: Disable Firewall and CDN temporarily
  5. Fix #5: Wait for DNS Full Implementation

Fix #1: Temporarily Disable Plugins and Themes

For WordPress website owners, the most common cause of 502 bad gateway errors is plugins or theme codes conflict with other elements on your site.

This conflict prompts the server to cancel queries and return the 502 errors.

If you notice this problem after updating or installing a new theme or plugin, deactivating them might be the solution.

If you can’t track the error back to a specific plugin, you should deactivate and then reactivate all your plugins.

Don’t worry.

It won’t affect anything on your website.

Just login to your WordPress Admin Dashboard, Go to Plugins and select Installed Plugins,

Untitled 78

Select all your Plugins and go to Bulk actions at the top of the page.

Choose Deactivate from the menu, then click the Apply button.

Untitled 83

This will disable all your plugins.

Now try and access your site to be sure the error has disappeared.

You can then re-install the plugins one by one to identify the culprit.

Once you find the plugin, look for an alternative plugin or if you can wait, contact the developer to help solve the problem or get a WordPress developer to help you.

Fix #2: Check Your Site Error Log

Checking your website error log can help you identify the cause of the 502 bad gateway error and what you can do to fix it.

You’ll need access to your hosting account dashboard to find the error log.

Follow these steps:

Log in to your hosting account and go to File Manager.

Untitled 86

Open the public_html folder. Search for the file with the name error-log.

On other platforms, it might be named debug.log.

Untitled 90

Double-click to open and read through the error log advisably from the bottom up.

You’ll see what went wrong and get a cue on how to fix it.

Fix #3: Restart Increase PHP Timeout Limit

The 502 bad gateway status code can also appear due to a PHP time-out error.

This happens when a single PHP process takes longer than the pre-configured maximum execution time and the request time out.

In this case, you can first restart PHP to fix any connectivity issues on your server.

You’ll find this option in your hosting account dashboard.

If this is not available in your dashboard, contact your hosting provider to help restart PHP.

By default, most hosting providers set the maximum execution time for a request to 300 seconds.

To increase this value on your server, open a support ticket and ask your host to increase the value.

Fix #4: Disable Firewall and CDN Temporarily.

A Firewall is an extra layer of protection between your server and the user’s browser.

However, Firewall can sometimes overdo their protection by interfering with server requests.

Hence, 502 bad gateway errors.

When there’s a problem with your Content Delivery Network CDN, it can present as a 502 bad gateway error.

The solution here is to temporarily disable your CDN if you use a third-party CDN.

But if you are using Cloudflare, it may take time to disable it because Cloudflare is a fully proxy service.

You should be aware that two cases of 502 bad gateway errors can occur in Cloudflare.

If you see a screen that looks like the one below, it means the problem is from Cloudflare.

But before reaching out to their support for a solution, check the Cloudflare Status Page to see if there are any issues.

It might be that scheduled maintenance is in progress.

Untitled 94

If the screen you see looks like this, then it means the problem is with your hosting provider.

So contact them to resolve the issue.

Untitled 99

Fix #5: Wait for DNS Full Implementation

If you’ve recently changed your website IP address or changed your hosting provider, it will affect your website DNS server.

So when visitors try to access your site, they’ll be served with 502 bad Gateway errors.

There’s nothing you can do in this case.

You’ll have to wait until the DNS changes are fully implemented.

More Helpful Troubleshooting Tutorial

  • How to Fix Error 500:What is the HTTP 500 internal server error? What causes it? And What can you do to fix it and get your site back online? Check out this guide.
  • How to Fix 429 Error: Do you see HTTP error 429 when trying to access a website? Find out the causes and fixes in this comprehensive guide.
  • How to Fix Your Connection Is Not Private: When web browsers fail to verify the SSL certificate on a website, they return the connection is not private message. Find the solution here.

Wrapping up

Now you know what to do when your next website serves 502 bad gateway to users.

If you think the steps above are too technical, you can call your host for help.

Do you think we miss anything?

Perhaps you’ve used other methods that work for 502 bad gateway errors.

Share it with us in the comment section below.

Leave a Comment