WordPress is a solid software that provides a smooth experience for website users. Well, at least most of the times. Like most other software, WordPress also has some flaws that cause certain errors and malfunctions.
The 502 Bad Gateway error is one of the terrible errors that often frustrates WordPress users. Mainly because this is an error that’s quite difficult to troubleshoot. You need to go through several steps to figure out what’s causing this error and fix it.
If you’ve been getting a 502 Bad Gateway error and have trouble using your WordPress site, don’t worry. It can be fixed. You just need a little bit of patience and follow the step-by-step instructions below.
What Is 502 Bad Gateway Error?
A 502 Bad Gateway error can be caused by many different things, but it mostly means there’s something wrong with your web server. And to explain what causes a 502 Bad Gateway error, you need to understand how websites work.
Whenever you visit a website, your browser sends a coded message to your server requesting the resources related to that specific page. Then the server sends back all the requested resources like the website design, layouts, images, etc, to show the webpage on your browser.
HTTP Status Codes are also included in this response sent from your web server. These codes aren’t shown to you unless there’s something wrong with the exchange process. The 502 Bad Gateway is one of the errors that show you the status code when the server discovers an invalid response while fulfilling a request.
What Causes This Error?
Unlike most other server errors, finding the cause of a 502 Bad Gateway error is difficult. There can be various causes from issues in your browser to incompatible plugins.
In most cases, the 502 error is shown when your web host takes too long to process an HTTP request. This usually happens when a server has to process too many requests for different websites, it’s especially common for shared hosting servers.
To figure out the real cause of the error, you need to go through a list of causes and see if it gets fixed.
How To Fix 502 Bad Gateway Error
Almost all of the methods for fixing the 502 error are beginner-friendly. You can even fix the error by yourself without any help from an expert.
Before making any changes to your website, always remember to backup your website.
Method 1: Hard Refresh The Webpage
As we’ve explained earlier, the 502 Bad Gateway error is mostly caused by server issues. But, oftentimes your browser may show this error even when the web host fixes the issue. To see if this error persists, try doing a hard refresh of the website.
To do a hard refresh (reload) of your website, simply press SHIFT + F5 for Chrome or CTRL + F5 for Firefox. This will reload the website from scratch by sending a fresh batch of the HTTP requests to your server.
Method 2: Clear Browser Cache
If reloading the website didn’t fix the 502 error, you can try deleting the browser cache. This will clear out all the saved data on a browser, such as cookies, cached images, and other bits of data related to websites and make your browser work like brand new.
To clear browser cache, press CTRL + SHIFT + DELETE on Chrome or Firefox to access the clear browser history window. Choose a time range and delete the cache.
See if this fixes your issue. If not, proceed to the next methods.
Method 3: Double Check Your Plugins & Themes
In rare cases, WordPress plugins could also cause your website to malfunction and send bad HTTP requests to your web server. This can happen when you install a new plugin or update a plugin to a new version.
To see if the 502 error is caused by a plugin or a theme, try resetting and disabling all of your plugins and then activating them one by one to see if the issue comes back. You can check the theme by switching to the default WordPress theme.
If you can’t access the WordPress admin area, you can reset and deactivate the plugins using an FTP client. Access the website files in your server using an FTP client. Browse to the WP-Content folder and then rename the Plugins folder. Just change the name from Plugins to something else.
This will deactivate the plugins on your WordPress website. Do the same for your themes. Except, don’t rename the Themes folder. Just rename the folder related to your active theme found inside the Themes folder. It will automatically revert your website to use the default WordPress theme.
Method 4: Disable The CDN
If you’re using a CDN (content delivery network) like Cloudflare, you should also try disabling your CDN to see if the issue is caused by the CDN service.
A CDN re-routes your website traffic through its own network of servers to reduce webpage load times. By disabling the CDN, you can send HTTP requests directly to your web server without any interference. See if this fixes the error.
Method 5: Check Your Web Hosting Provider
If none of the above methods worked, then it’s time to check with your web hosting provider. Before contacting the web host, check the Twitter and Facebook pages of your web hosting company to see if they’ve made any announcements related to server issues.
If not, use the support section to submit a support ticket or use live chat to reach your web host and ask what’s causing this issue.
Most of the time, the 502 error is caused by issues with your web host, especially if your web host has recently moved servers to a different location. But, it’s always best to check things on your side before contacting your web host to save time.
If the methods we’ve described didn’t work, it’s probably the time for you to move your website to a better web hosting provider, preferably to a managed WordPress hosting platform.