502 bad gateway error One of the most frustrating aspects of running a website is having to troubleshoot an error when you don’t know why it’s happening. Some issues, such as the 502 bad gateway error, have many potential causes. This means you may need to try multiple solutions before you land on the right one. In this post we’ll show you how to navigate this tricky error and resolve it.
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.
Bad gateway error is one of the common WordPress errors that you may encounter on your site. It can be caused by a number of reasons and depending on your server the error message may also differ in looks slightly.
How to Fix the 502 Bad Gateway Error
1. Try Reloading the Page
One of the easiest and first things you should try when encountering a 502 bad gateway error is to simply wait a minute or so and reload the page (F5 or Ctrl + F5). It could be that the host or server is simply overloaded and the site will come right back. While you’re waiting, you could also quickly try a different browser to rule that out as an issue.
2. Clear Your Browser Cache
Whenever you encounter issues like these it can be good to clear your browser cache
3. DNS Issue
A 502 bad gateway error could also be because of a DNS issue, such as the domain is not resolving to the correct IP. If you have just migrated your WordPress site to a new host, is it important to wait for things to fully propagate, which can take up to 24 hours in some cases. This depends upon the TTL value of your DNS records.You can also try flushing your local DNS cache. This is similar to clearing your browser cache.
4. Disable the CDN or Firewall
If you are using a CDN service or website firewall on your website, then it is possible that their servers are acting up. To check this, you will need to temporarily disable CDN.
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 again.
5. 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 resolved.
If it is, 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 find an alternative plugin or contact the plugin author for support.
If deactivating plugins didn’t solve your issue, then you would want to check your WordPress theme. You will need to switch 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 bad gateway error, then continue reading.
6.Check the Hosting Server
If all above-mentioned troubleshooting steps failed, then it is likely an issue with your hosting server.
You need to contact your hosting provider’s support team and let them know 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 is caused by a server misconfiguration.
That’s all. 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 for step by step instructions on fixing your WordPress issues.
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.