9 Ways to Fix 502 Bad Gateway Error on Your WordPress Site
Table of Contents
- What is a 502 Bad Gateway Error?
- Variations of the 502 Bad Gateway Error Message
- What Causes the 502 Bad Gateway Error?
- Why You Should Try to Fix the 502 Gateway Error
- How to Fix a 502 Bad Gateway Error on Your WordPress Site
- 1. Reload the Page
- 2. Check if the Website is Available
- 3. Restart Your Internet Router
- 4. Clear Your Browser Cache
- 5. Flush Your DNS Cache
- 6. Change Your DNS Address
- 7. Temporarily Disable Your Firewall, CDN, and Proxy
- 8. Deactivate Plugins and Themes
- 9. Contact Your Host
There’s no shortage of errors you’ll experience on WordPress – but that’s not us saying it’s no good – it’s great, in fact. The thing is, errors and using the Internet pretty much come hand in hand. The 502 Bad Gateway error is not limited to WordPress – it can happen on just about any website, big or small. Facebook, Gmail, Twitter, Cloudflare – all these giants occasionally suffer the 502 Bad Gateway hiccup. It’s only “natural.”
Error 502 Bad Gateway
But just because it’s a normal occurrence, doesn’t make it any less frustrating (like your car breaking down or your parents inquiring about your dating life). Well, we’ve prepared this article so that you can put an end to the 502 Bad Gateway error and uh, reduce the stress in your life.
While some of the time the 502 Bad Gateway error resolves itself quickly, there are some cases where it will take a bit of elbow grease on your part. Not to worry! We’ll go over what causes this error code and how you can fix it. We’ll troubleshoot and go over the easy solutions you can try to resolve the 502 Bad Gateway error, and you’ll have your WordPress website up and running again in no time!
What is a 502 Bad Gateway Error?
Various 500 error codes indicate different issues. 502 Bad Gateway means miscommunication between servers. The HTTP 503 Bad Gateway error is a response code which indicates that one server received an invalid response from another server. Basically, the server which acted as a gateway (the reverse proxy server) didn’t get the necessary information from the upstream server (origin server) so it didn’t process the request.
But let’s get into it a bit more to gain a better understanding of what that means.
Most web applications are hosted on multiple servers. WordPress is no exception – various parts of the platform are backed by different servers. For instance, WordPress is hosted by:
- A database server that supports the databases of different WordPress users
- A web server that supports the files on WordPress websites
- An application server that supports the various functionalities of the WordPress application – like login information, PHP code, and so on
- A gateway server (or reverse proxy server) which runs website software like Apache and NGINX
So as you can imagine, opening a website that runs on multiple servers, like WordPress, means that there’s a whole lot of requests sent between servers for the content to come together and the page to load properly.
So essentially, the 502 Bad Gateway error happens when one of the upstream servers (web server, database server, application server) sends an invalid response to the reverse proxy server.
In the 502 error code, the reverse proxy server is basically telling you that it couldn’t retrieve the content you needed.
Variations of the 502 Bad Gateway Error Message
The 502 Bad Gateway error wears many hats. Underneath those hats, is the same old issue. Depending on the browser, operating system, or server that you’re using, the 502 Bad Gateway error may appear as any of the following variations:
- “502 Bad Gateway”
- “HTTP Error 502 Bad Gateway”
- “502 Service Temporarily Overloaded”
- “Error 502”
- “502 Proxy Error”
- “HTTP 502”
- “502 Bad Gateway NGINX”
- “Temporary Error (502)”
- “502 Bad Gateway Cloudflare”
- “502 – Web server received an invalid response while acting as a gateway or proxy server. There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.”
- “502 Server Error: The server encountered a temporary error and could not complete your request”
- “502. That’s an error. The server encountered a temporary error and could not complete your request. Please try again in 30 seconds. That’s all we know.” (Appears on Google)
- “Bad Gateway: The proxy server received an invalid response from an upstream server”
- A blank white screen may also be an indication of the 502 Bad Gateway error.
Another variation of the 502 Bad Gateway error code which explains the issue and proposes how you can fix it
As you can see, in some cases you’ll just get the error code, and in other cases the server may do a little troubleshooting to inform you of what may have caused the error. It may even suggest that you try loading the website again after several seconds, which is always a good idea.
What Causes the 502 Bad Gateway Error?
Sometimes the 502 bad gateway error is caused by server miscommunication and there won’t be much for you to do except wait around. Some server-side errors include:
- One or all of the upstream servers are down
- The server is overloaded (when Twitter displays the 502 error, the message reads “Twitter is over capacity.” Too many visitors can overload a website and cause this error.)
Other times it may be caused by something on your end. In these cases, it’s up to you to fix it and get your WordPress website up and running again! Some possible issues on your end are:
- Outdated browser cache or WordPress cache
- Misconfigured/faulty WordPress themes or plugins causing issues with the PHP script
- Faulty Google extensions
- Problems with your Internet connection
- Issues with the DNS (domain name system)
- Issues with the CDN (content delivery network)
If the issue is on your end, there’s plenty you can do to get it fixed. We’ll go over the various easy solutions to the problem in a moment – but first, one last thing.
Why You Should Try to Fix the 502 Gateway Error
If the problem is on your end, it’s crucial that you try to fix it as soon as possible. No pressure, but waiting around isn’t a great idea because a long-standing 502 error can have a negative impact on your website’s SEO ranking. There’s a big difference between your site being down for 5-10 minutes, and it being down for over 6 hours.
The issue is that Google crawlers will note the problem if it lasts too long. Namely, if the 502 bad gateway error is only around for 10 minutes before you get it fixed, the Google crawler will get the page information from the cache. Or maybe the crawler won’t even get to visit your website before you get it up and running again.
But if your website is down for hours on end, the Google crawler may identify the error code as a site-level problem, which could negatively impact your SEO rankings. Your website may be bumped down later in the search results, and no one wants that to happen (especially not you!).
So without further ado, let’s look at several solutions you can try to fix the 502 Bad Gateway error on your WordPress website.
How to Fix a 502 Bad Gateway Error on Your WordPress Site
The 502 bad gateway error may be a server-side or a client-side issue. We’ll cover some easy solutions that you – the client – can try in order to fix it, and then also go over what you should do if the issue stems from the server.
1. Reload the Page
OK, this does seem very simple and straightforward, but sometimes the simplest solution is the best one. If you, by chance, didn’t try reloading the page, do so! Either click the little reload button in your browser, or hit the F5 key on your keyboard. If the issue was on the side of the host – due to an overloaded server or a temporary glitch – your site may be up and running again by now.
2. Check if the Website is Available
Another thing you can try in order to identify the root of the problem is to check if the website is available for others and only down for you. If the website turns out to be only down for you, then it’s likely that the problem can be fixed in-house – namely, by adjusting your browser settings, your DNS address, or resetting that moody, pouty router in the corner of your living room.
If, on the other hand, the website turns out to be down for everyone – and not just you – there are two possible answers to what’s causing the problem:
- Client-side issue: a problem with your WordPress website due to faulty plugins or themes. We’ll go over how to fix this in a bit.
- Server-side issue: the website’s server is down. In this case, you should contact your host, which is what we’ll cover in this article as well.
To check if the website is down for everyone or just you, visit Down for Everyone or Just Me, and you’ll get your answer in a matter of seconds.
Visit Down for Everyone or Just Me to see if the website is down for everyone or just you
Type the domain of your WordPress website into the search bar and select or just me? This handy website tool will let you know if the website is offline, that is, down for everyone, or if it’s only down for you.
Let us then look at some ways to resolve the issue in both cases. We will first go over what you can do if the problem is isolated to you, and then what you can do if the website is down for everyone.
3. Restart Your Internet Router
We’re back to the good old have you tried turning it off and on again? The reason why you’re getting the 502 bad gateway error may simply be that your router is at it again.
To restart your router, simply turn it off by pressing its power button or unplug its cable. Wait for about 40 seconds, and then turn it on again, or plug it back in. Once the router reboots and all the pretty lights on it are glowing, try loading the website again. Still down? No worries, let’s keep going!
4. Clear Your Browser Cache
All browsers (Chrome, Mozilla, Microsoft Edge) store the data from your previous internet activity in their cache. This is information such as browsing history, login details, and cookies, which enable the browser to display the websites more quickly and smoothly on your upcoming visits.
Sometimes, though, the browser cache can contain outdated information that will do more harm than good, and cause issues like the 502 bad gateway error message. This may be because the website has been updated to a newer version since your last visit (like it can be a WordPress update that you weren’t aware of), and a glitch caused by old cache can cause it to malfunction.
The easiest way to check if the 502 error code is caused by outdated browser cache is to try opening the website in Incognito mode. When a browser, like Chrome, is in Incognito mode, it doesn’t store the regular data that ends up in your cache, like previous internet searches (i.e. browser history), login details, or cookies.
If you manage to access the website in Incognito mode, it’s quite possible that the issue is caused by your browser’s outdated cache. So the next step would be clearing the cache. We will use Google Chrome as an example to go through these two steps.
To check if the website loads in Incognito mode, select the Customize and control Google Chrome button at the top right corner of the screen, and click on New Incognito Window. Or, you could just hit Shift + Ctrl + N at the same time.
You can click on New incognito window or press Shift + Ctrl + N to open Chrome in Incognito
Try loading the website in Incognito.
If the website loaded without the 502 bad gateway error, you now need to delete your browser cache.
To clear your browser cache:
- Go to Customize and control Google Chrome > More Tools > Clear browsing data. Alternatively, press Ctrl+Shift+Delete.
How to clear your browsing data in Chrome
- Check all the boxes to clear your entire browsing data. This includes:
- Browsing history
- Cookies and other site data
- Cached images and files
Check all the boxes to clear your browsing history
- Click on Clear data.
- Restart your browser. Close your browser window and then open it again, to make sure that the changes have taken place.
- Try loading the website again. If the issue was caused by outdated browser cache, you should now be able to access it without the 502 bad gateway error!
5. Flush Your DNS Cache
Playing around with your DNS settings can get the 502 bad gateway error fixed. An outdated DNS cache is one of the things that may be causing the issue.
Flushing your local DNS cache, like clearing your browser cache, can work to fix the 502 bad gateway error. And doing it is really easy.
To flush your DNS cache:
- Go to your Command Prompt. You can do this by typing CMD into the search bar at the bottom of your screen, or pressing the Windows key and then typing in CMD.
Your Command Prompt will pop up
- Type in ipconfig /flushdns next to your PC’s username, and then hit Enter to flush your DNS cache.
Type ipconfig /flushdns into your CMD to flush your DNS cache
If the flush was successful, the screen will show the following two lines:
Windows IP Configuration
Successfully flushed the DNS Resolver Cache.
- Reset your PC. You’ll need to restart your computer for the changes to take effect.
- Try loading the website again. If the issue was caused by outdated DNS cache, you should now be able to access your WordPress website without the 502 bad gateway error.
6. Change Your DNS Address
Normally, your DNS is obtained automatically by your internet provider. See:
By default, your DNS and IP addresses are obtained automatically
In some cases, the automatically obtained DNS can be the source of the 502 bad gateway error if the server is overloaded or down.
Not to worry – changing your DNS address is both easy and safe.
For this step, we recommend using one of two popular public DNS addresses – either Google’s or Cloudflare’s free DNS’s. They’re both fast and reliable, so it’s up to you whether later on you want to stick to them, or just use it as a temporary measure to resolve the 502 error.
Note: If you’re already using one of these public DNS addresses, the solution may be reverting back to an automatically obtained DNS address. So if that’s the case for you, just click on Obtain DNS server address automatically from the appropriate window.
Changing Your DNS Address in Windows:
- Go to Control Panel.
- Go to the Network and Sharing Center. Type in “network” into the Control Panel search bar to find it more quickly.
- Click on Change adapter settings. As you can see from the image below, it’ll be on the left side of the window.
Select change adapter settings from the Network and Sharing Center
- Left-click on the Wi-fi icon. Select Properties.
Click on Properties to reconfigure your DNS address
- Click on Internet Protocol Version 4 (TCP/IPv4), and then on the Properties button below the list.
Select Properties to change your DNS address
- Check the circle next to Use the Following DNS Server Addresses.
- Type in the new values for the DNS address of your choosing (Google or Cloudflare) in the Preferred DNS server and Alternate DNS server fields.
If you want to use Cloudflare’s public DNS, type in the following values:
22.214.171.124 for Preferred DNS server
126.96.36.199 for Alternate DNS server
Write in the numbers corresponding to Cloudflare’s DNS address
If you want to use Google’s public DNS, type in the following values:
188.8.131.52 for Preferred DNS server
184.108.40.206 for Alternate DNS server
Write in the numbers corresponding to Google’s DNS address
- Click on OK.
- Restart your browser, i.e. close it and open it again.
- Try loading the website again. If the issue was DNS address, you should now be able to access the website.
Changing Your DNS Address in Mac:
- Go to System Preferences > Network > Advanced.
- Select the DNS tab from the top row of the window.
- Click in the text box on the window on the left side, titled DNS Servers.
- Write the corresponding values for the new DNS address in the text box.
If you want to use Cloudflare’s public DNS, type in the following numbers:
220.127.116.11 in the first line;
18.104.22.168 in the second line.
If you want to use Google’s public DNS, type in the following number:
22.214.171.124 in the first line;
126.96.36.199 in the second line.
- Click OK.
- Restart your browser, i.e. close it and open it again.
- Try loading the website again. Hopefully, the issue has been resolved!
7. Temporarily Disable Your Firewall, CDN, and Proxy
The 502 bad gateway error could be caused by your firewall, CDN (content delivery network) or proxy. To check if one of them is the culprit, simply disable each of them, one by one, temporarily. After disabling each, reload the page and see if it worked.
If you’re using a CDN plugin, like this free CDN Enabler plugin, deactivate it from your WordPress admin dashboard and then try loading your website again. If you can’t access your WordPress admin dashboard, check out the next step on how to disable plugins via FTP client.
If you’re using a proxy like Cloudflare, and you think that it’s causing the issue, unfortunately you won’t be able to disable it. All you can do is contact them about the error code and wait for them to fix it.
8. Deactivate Plugins and Themes
Up to this point, we’ve been going over fixes for the 502 bad gateway error if the website is only down for you. From this point on, we’ll be looking at what you can do to fix the error if it’s causing the website to be down for everyone.
The first thing you can try is temporarily deactivating your WordPress themes and plugins, to see if one of them is causing the issue. Since many WordPress plugins and themes are made by independent web developers from around the world, there’s no making sure that they’re are bug-free or even regularly updated.
Misconfigured plugins can cause the 502 bad gateway error. This can especially happen with caching plugins, if they keep outdated information, which may cause your website to malfunction.
How to Disable Plugins from the WordPress Admin Dashboard
If you can access your WordPress admin dashboard, disabling plugins is quite simple.
- Select the Plugins tab from the options on the left side of the screen.
- From the Bulk Actions menu, click on Deactivate. This will deactivate all your plugins.
Deactivate all plugins from the Bulk Actions menu
- Now, reload your WordPress website and see if that worked.
- If your website loads properly, it means that one of the plugins was causing the 502 bad gateway error. Begin reactivating the plugins one by one. Reload the page after each activation. When the website shows the 502 error again, you’ll know which plugin was causing the issue. Now, you can deactivate it permanently, and contact the developer about the problem.
How to Disable Plugins if the WordPress Admin Dashboard Isn’t Working
In some cases, you may be seeing the bad gateway error even on your WordPress dashboard. Not to worry! You can also disable WordPress plugins via FTP client.
- Connect to your website via FTP client.
- Go to WordPress installation directory.
- Locate the wp_content/plugins folder.
- Change the name of the plugins folder to plugins_old. Renaming the folder will deactivate all plugins from your WordPress website.
- Try loading the website again, as well as your admin dashboard. If they load properly, you know that one of the plugins is in fact causing the 502 bad gateway error.
- Go back to FTP and change the name of the plugins folder back to plugins. This will reactivate all plugins.
- Test each plugin one by one. To find out which particular plugin was causing the issue, rename each plugin one by one to deactivate them. Try reloading the website after each deactivation. When the page loads, you’ll have found the guilty plugin.
How to Disable Themes from the WordPress Admin Dashboard
Just like plugins, themes are also created by independent web developers. A faulty theme code or an incompatibility between a theme and a plugin can cause the 502 bad gateway error.
A faulty theme may be causing the 502 bad gateway error
In order to check if a theme is causing the problem, you’ll need to temporarily deactivate your custom themes and revert back to a WordPress default theme, like Twenty Nineteen or Twenty Twenty.
- Go to Appearance > Themes. Activate the default WordPress theme. (You can also just deactivate your custom theme, and WordPress will automatically revert back to the default theme.)
Go to Themes to revert back to the default WordPress theme
- Reload the page. Try loading the website again to see if reverting back to the default theme fixed the problem.
How to Disable Themes if the WordPress Admin Dashboard Isn’t Working
We’ll do the same for themes that we did for plugins – disable custom themes via FTP client.
- Connect to server via FTP client.
- Locate the wp_content/themes folder.
- Change the name to themes_old.
- WordPress will automatically revert back to the default theme.
- Try loading the page again. If the page loads successfully, a faulty custom theme was causing the 502 bad gateway error.
What you can do – if you’ve discovered that a theme is misconfigured – is contact the theme’s developer so that they can work on fixing it.
9. Contact Your Host
So far, we covered how you can fix the problem if it’s:
- Isolated to your browser
- Related to your WordPress settings
However, the 502 error most commonly appears due to an issue with your web host’s server. In this case, there’s nothing you can do to fix it. But what you can and should do, is contact your hosting provider.
One way in which the server may be responsible for the error is that if a request takes too long to process, it’s automatically canceled by the server via “kill script.” This is a measure to prevent long loading processes from affecting other users.
The other thing that may be behind the 502 bad gateway error is if your server is down. In addition to contacting your host, you can also open a support ticket on WordPress and see if the issue has to do with their servers.
Hopefully, our guide was helpful for you to resolve the 502 bad gateway issue. The various solutions we went over should – at the very least – help you get to the root of the problem.
The first thing you can try is to see if the error stems from your PC’s browser.
The next step to resolving the issue, if your WordPress website is down for everyone, is to adjust some WordPress settings (plugins and themes) to get the website up and running again.
The last step is contacting your web host. They’re there to help! Once you’ve notified them about the issue, your website should be up and running again soon.
Try the free CSS tidy up which lets you beautify stylesheets for your websites.
View Related Articles
Emailing today is such an easy task. Compose, hit send, and your message travels across oceans and borders to reach its recipient. It is such an easy task that people’s attention starts to drown in their full inboxes, which are also littered by spammers, phishers and other members of the not-so-nice population of netizens.
But what are redirects, and why are they important? What are the different types of redirects? We’ll fill you in on everything you need to know about redirects, and most importantly – how to do them on your WordPress site.
What are the benefits of opting for a dedicated IP? And perhaps most important of all – do you really need one? Let’s take a closer look at all the questions surrounding dedicated IPs so that you can better understand who needs a dedicated IP and when.