502 Bad Gateway

502 Bad Gateway

Recently while working on a client’s website, the issue of a 502 Bad Gateway error came up.  During this error, the cPanel was accessible but the site & WordPress login was not.  After a bit of searching for a viable solution, the answer was a surprisingly straight forward – one of the plugins had become corrupted during an update.

Before checking the plugins, be sure to double check your site with a disabled/clear cache.  It does not matter if you use the developer tools or Private/Incognito mode for this step, the end result is the same. 

To check if the plugins are the root of your 502 error, use the cPanel (or your applicable alternative file manager system) to navigate to the wp-content folder and rename the plugins folder. Something along the lines of plugins-test will work just fine.  After renaming this folder, refresh your site.  If it loads (albeit, probably looking a bit funky) then the issue did come from a plugin.  Assuming this is the case, rename the folder back to plugins, then enter the folder and append -test to all of the plugins.  One by one, change the plugin name back and refresh your site (with a clear cache).  When you hit the 502 error again, that’s the plugin causing the issues.  Unfortunately, you’ll need to delete that bad plugin and either bring it back with a backup or reinstall – and reimplement – from scratch.

To better keep solutions organized, if I experience the 502 Bad Gateway error again and find an alternative solution, I will add that to this page.  I hope this helps reduce some of the troubleshooting confusion out there.

Thank you for your time,

– Rett