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. Plus, the error message doesn’t provide exact pointers on how to fix it.
In this article, we will show you how to easily fix the 502 bad gateway error in WordPress.
What Is a 502 Bad Gateway Error?
A 502 bad gateway error happens when your WordPress hosting server gets an invalid response for the requested page. This issue can be caused by various things, and the error message may vary depending on your server.
When a user visits a WordPress website, their browser sends a request to the hosting server. which then retrieves the page and sends it back to the browser.
If an error occurs, the browser displays an error status code, such as 502 Bad Gateway.
The most common reason for a 502 bad gateway error is that your request took too long for the server to respond.
The most common reason for this error is a delay in the server’s response to your request. This delay could result from temporary glitches due to high traffic, poorly coded WordPress themes or plugins, or server misconfigurations.
Now, let’s take a look at how to easily fix the 502 bad gateway error in WordPress. Feel free to use these quick links to skip to a specific solution:
Reload Your Website
Sometimes, your server may take longer to respond due to increased traffic or low server resources. In that case, the problem could automatically disappear in a few minutes.
You should try reloading the web page that you are viewing to see if this is the cause. If this fixes 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.
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 clear your browser cache, read our guide on how to clear your browser cache in all major browsers. You may also want to clear your WordPress cache as well.
Additionally, consider using a different browser to troubleshoot if the problem is happening because of the browser cache.
Still seeing the error in all browsers? Go ahead and continue reading.
Disable the CDN or Firewall
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. If the issue was caused by the CDN or firewall service, then it should be resolved now.
After that, you can contact your firewall or CDN service provider for support and solutions on how to enable it back properly.
Update Your WordPress Themes and Plugins
At times, the 502 bad gateway error may be caused by outdated themes and plugins. To see if this is true, you have to check them one by one.
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, consider checking 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.
Restore a WordPress Website Backup
For people using a backup plugin with their backups stored in a remote storage location, it may be a good time to restore one of these backups. This way, you can get your website back up and running just like before the error occurred.
For more information about backup restoration, read our beginner’s guide on how to restore WordPress from backups.
Now, if this solution fails as well, then you may want to consider this next step.
Expert Tip: Backups are an easy way to keep your website safe from unexpected errors or disasters. If you are wondering which backup plugin you should use, then we recommend Duplicator.
Contact Your Hosting Provider
The last solution is to reach out to your web host’s support, as it’s likely that the issue is on their end.
Make sure to let them know about the issue and 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.