Beginner's Guide for WordPress / Start your WordPress Blog in minutes

How to Fix the 502 Bad Gateway Error in WordPress

Are you seeing the 502 bad gateway error on your WordPress site?

This error is quite annoying because it can be caused by a lot of different things. This means troubleshooting the 502 bad gateway error can take some time.

In this article, we will show you how to easily fix the 502 bad gateway error in WordPress.

How to fix the 502 bad gateway error in WordPress

What Is a 502 Bad Gateway Error?

A 502 bad gateway error is triggered when your WordPress hosting server gets an invalid response for the requested page.

The bad gateway error is one of the common WordPress errors that you may encounter on your WordPress website. It can be caused by a number of reasons, and depending on your server, the error message may look slightly different.

502 bad gateway in browser

When you visit a website, your browser sends a request to the hosting server. The hosting server then finds the page and sends it back to your browser with the status code.

Normally, you won’t see this status code. However, if there is an error, then the status code is displayed with an error message.

Examples of these error messages include 404 not found, 503 service unavailable, 403 forbidden error, and more.

The most common reason for a 502 bad gateway error is that your request took too long for the server to respond.

This delay can be a temporary glitch caused by high traffic. It could also be caused by a poorly-coded WordPress theme or plugin. Last but not least, it can also happen due to a server misconfiguration.

That being said, let’s take a look at how to easily fix the 502 bad gateway error in WordPress.

Fixing the 502 Bad Gateway Error

This error is usually caused when your server is unable to find the cause of the invalid response. This means that we will try different troubleshooting steps until we find the problem.

Step 1: Reload Your Website

Sometimes your server may take longer to respond due to increased traffic or low server resources. In that case, the problem may automatically disappear in a few minutes.

You should try reloading the web page that you are viewing to see if this was the cause. If this fixed your problem, then you do not need to read any further.

However, if you see this error frequently, then you will need to continue reading, as there may be something else that needs fixing.

Step 2: Clear Browser Cache

Your browser may be showing you the error page from the cache. Even after the issue is fixed, you will see the 502 error because the browser is loading your website from its cache.

To fix this, users with Windows/Linux operating systems can press the Ctrl + F5 buttons, and macOS users can press the CMD + Shift + R buttons on their keyboards to refresh the page and reload the cache.

You can also delete the cache manually from your browser settings.

Clear browser cache

For more details, see our guide on how to clear your WordPress cache. Then, try loading the website again.

You can also use a different browser to troubleshoot if the problem is happening because of the browser cache. If you see the error in all browsers, then continue reading.

Step 3: Disable the CDN or Firewall

If you are using a CDN service or WordPress firewall on your website, then their servers could be acting up.

To check this, you will need to temporarily disable the CDN or firewall. This process will be different depending on which service you are using.

Once disabled, it will remove the additional layer that has been created between your browser and the hosting server. Your website will now load entirely from your server, and if the issue was caused by the CDN / firewall service, then it will get resolved now.

You can then contact your CDN service provider for support. Once the issue is resolved, you can go ahead and enable the CDN or firewall again.

Step 4: Update WordPress Themes and Plugins

If the error is still there, then the next step is to check your theme or plugins.

First, you will need to deactivate all WordPress plugins via FTP. After that, visit your website to see if the error has been resolved.

If it has, then one of your plugins was causing the issue. You now need to activate all plugins one by one until you can reproduce the error. This will help you locate the plugin responsible for the error.

You can then look for an alternative WordPress plugin or contact the plugin author for support.

If deactivating plugins didn’t solve your issue, then you need to check your WordPress theme. You will need to switch your WordPress theme via phpMyAdmin.

After switching your theme to the default WordPress theme, visit your website to see if it’s working. If you are still seeing the error, then continue reading.

Step 5: Check the Hosting Server

If all the troubleshooting steps above didn’t work, then it is likely an issue with your hosting server.

You will need to contact your hosting provider’s support team and let them know about the issue. You can also mention all the troubleshooting steps you have taken.

All good WordPress hosting companies will be able to quickly fix the issue if it was caused by a server misconfiguration.

You can also check out our guide on how to properly ask for WordPress support and get it.

We hope this article helped you learn how to fix the 502 bad gateway error in WordPress. You may also want to see our complete WordPress troubleshooting guide and our expert picks for the best email marketing services to grow your website.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

2 CommentsLeave a Reply

  1. Just a suggestion really. If the error is only when you try to go directly to wp-admin or anything on the admin area, it may be because the wordpress site cannot log you in. If you have security which limits your login attempts this may be the case. Try logging in as a user first and see if it warns you to ‘try again in 20 minutes’ or similar. Waiting should fix this issue.

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.