Looking for a solution for the 502 Bad Gateway error in WordPress? If so, we’ve prepared a set of troubleshooting steps to get rid of the annoying message. And it’s not only annoying – you should correct the issue as soon as possible so it doesn’t affect your website’s Google ranking. A few minutes to a half-hour of downtime shouldn’t hurt you, but a couple of hours can be dangerous. Trouble is, the problem could come from your website configuration or newest update, hosting, or the network in-between. We’ll cover each of those sources as we show you how to fix the 502 Bad Gateway error in WordPress.
502 Bad Gateway error variations
Based on your browser, hosting, web server, operating system, and device, the 502 Bad Gateway can have some of the following error codes:
- Error 502
- 502 Proxy Error
- White screen of death
- HTTP 502
- 502. That’s an error.
- Temporary Error (502)
- Error: Server Error
Some even point you at the cause, which is a relief. Here are 10 methods to get rid of the 502 Bad Gateway error in WordPress:
1. Reload the page
Did you know that reloading the website can lead to solving the 502 Bad Gateway error in WordPress? Press F5 or Control + F5 on Windows or Command + Control + R on Mac. You can also click the spinning arrow on the (usually) top left side of the browser window.
2. Verify whether your website is online
You can use an external service to check for the status of your website. There are plenty of services out there, but we like IsItDownRightNow or Down for Everyone or Just Me. If the website shows as online, you know the problem is on your side.
3. Delete browser cache
There’s a chance that your website is being loaded from cache, even if you fixed the error already. We’ve already demonstrated how to clean browser cookies and cached data in Google Chrome and Safari. Check the 1st method in our guide on how to fix WordPress keeps logging out problem, then reload the website again.
Didn’t work? Here’s how to clear cache on WordPress manually. That method encompasses all caching plugins for WordPress since they all store cached files inside the same folder. You can also follow these steps to clear WP Rocket cache.
4. Fix the DNS issue
Your website uses a DNS (Domain Name System) so you can type yourwebsite.com instead of typing the IP address to load its contents. Here are 2 possible solutions for this problem:
1. Migrated your website from one hosting to another recently?
If so, you should know that the transition isn’t instant, and you’ll likely see the 502 Bad Gateway error in the meantime. It can take up to 48 hours for everything to settle down, and the error will go away on its own.
2. Flush your local DNS
There’s a chance that your local DNS is malfunctioning, which results in the 502 error. Here’s a quick set of instructions to flush your DNS:
Flushing DNS on Windows works like this:
- Click on the Start orb.
- Type ‘cmd’
- When Command Prompt is selected, click on Run as administrator.
- Type this:
ipconfig/flushdns - Press Enter.
- You’ll see a ‘success!’ message.
These are the instructions to flush DNS on macOS:
- Click the Launchpad icon.
- Search for ‘Terminal’, and select Terminal.
- Type the following:
dscacheutil -flushcache - Press Enter or Return.
- There’s no success message, even when it is.
5. Disable your CDN temporarily
A CDN (content delivery network) you installed to speed up your website might be the source of the 502 Bad Gateway error. Do you use Cloudflare, WP Rocket, KeyCDN, or similar services? Also, do you have any security plugins for WordPress? Access the WordPress Admin Section and check whether you can deactivate such plugins or services. By doing so, you remove the intermediary, and the static content will load directly from the website, thus fixing the issue.
6. Check your hosting error log
A lot of hosting providers, such as Kinsta hosting, offer an error log option inside their cPanel/Dashboard. Log in and check if the option exists with the hosting you use. If you’re lucky, you might get an exact file name and line number the error occurs on. If you can’t find the option, you can also use enable PHP errors by following method 9 in our Locked out of WordPress Admin Section? article.
7. Restart PHP or update PHP version
This is also done via the cPanel e.g. your hosting Dashboard. Find a section dedicated to PHP, and first restart it. If it doesn’t make a difference, updating is easy – you’ll get a drop-down list to select a newer version from. Click OK or Apply, and check whether you got rid of the pesky error message.
8. Increase your PHP timeout value
Have you tried importing a large file, function, plugin, or theme before the error occurred? If so, there’s a strong chance you triggered a WordPress safeguard that prevents a process from running for too long. Depending on what you were doing, check our guides on increasing maximum file upload size or fixing the “Maximum execution time exceeded” WordPress error.
9. A plugin or theme might be the culprit
The easiest way to diagnose the problem is to disable all WordPress plugins. Check our guide on solving the “Are you sure you want to do this” error in WordPress and follow the steps under the headline Fixing the problem if the plugin caused it. If you solve the 502 Bad Gateway WordPress error, simply enable plugins one by one until you find the problematic one.
Made changes to your active theme or installed a new WordPress theme recently? You can easily disable it temporarily. Follow the 1st method in our guide to delete WordPress themes, but click on Deactivate instead of Delete.
10. Contact your hosting Customer Service
If nothing worked, the server your website is hosted on is likely the problem. For example, your hosting’s firewall can block the requests from your CDN and thus produce the 502 Bad Gateway message. The only way to solve the problem is to contact your hosting – they’re available 24/7 via live chat or an internal ticket system.