Every time you visit a website your browser sends a request to a web server. The web server receives and processes the request, and then sends back the requested resources along with an HTTP header and HTTP status code. The 502 Bad Gateway error specifically means that the server received an invalid response from an inbound server.
Variations
The 502 Bad Gateway error can look different depending on the browser, web servers and OS you’re using. Here are some of the variations you may have encountered:
- 502 Bad Gateway
- Error 502
- HTTP Error 502 – Bad Gateway
- 502 Service Temporarily Overloaded
- 502 Proxy Error
- A blank white screen
- 502 Server Error: The server encountered a temporary error and could not complete your request
- HTTP 502
- Temporary Error (502)
Regardless of this, the 502 bad gateway error always has the same meaning.
How to fix it?
1. Try reloading the page
Let’s begin by ruling out the simplest and most common causes. More often than not, the 502 gateway error shows up due to an overloaded server. If this is the case, then the issue will resolve itself in a matter of minutes and all you have to do is wait and refresh the page.
2. Clear your browser cache or use a different one
A 502 bad gateway error can also be a client-side issue. We recommend clearing your cache or visiting your website using another browser just to be sure it is down for everyone and not just you.
3. Clear your local DNS cache
Maybe the domain is not resolving to the correct IP, or the DNS server is not responding. If you just migrated your website to a new host, it is possible the DNS hasn’t fully propagated.
Related: What is DNS propagation?
You can also try clearing your local DNS cache. If you are using Windows, open the Command Prompt and enter the following code:
ipconfig /flushdns
You’ll see a “Successfully flushed the DNS resolver cache” once the process is done.
If you are a macOS user, enter the following code in the terminal:
dscacheutil -flushcache
4. Contact your hosting provider
Your hosting provider may have lost connection to the server. They could also be doing server maintenance. Regardless of the reason, we recommend you open a ticket or get in touch with them just to make sure that they are aware and working on the issue.
If they have access to the server and everything seems to be working just fine, they could still provide further assistance by having experts look into the problem.
5. Temporarily Disable CDN or Firewall
The error can also be caused by your content delivery network (CDN) or firewall. If you are using a 3rd-party CDN provider, you can try disabling your CDN temporarily and checking your website again.
This can also occur sometimes with DDoS protection providers like Cloudflare. If you’re currently using Cloudflare, you may be seeing one of the screens pictured below. They both mean different things and can give you an indication of where the problem originated.
The following screen indicates an issue on Cloudflare’s end. You can reach out to them through their support channels, but it might be quicker to check their status page or social media profiles to see if they’re experiencing an outage.
However, if you see the following screen, this indicates a problem with your hosting provider.
6. Check your plugins and themes
If you recently installed a plugin or a new theme on your WordPress, snippets of bad code could be the culprit here. A few ways you can troubleshoot this is by deactivating all your plugins or switching your theme. You won’t lose any data by doing this.
If you can still access your administrator dashboard, you can manage your plugins by navigating to the Plugins section using the left sidebar. You can begin by disabling the ones you suspect could be causing the problem and continuosly checking your website to see if it starts working.
If you can’t access your WordPress dashboard, try using FileZilla or another FTP client to connect to your server and rename your plugins folder. Then check your site again. If it works, then you will need to test each plugin one by one. Rename your plugin folder back to “plugins” and then rename each plugin folder inside of it, one by one, until you find the one that’s causing the issue.
Related: What is FileZilla? How do I connect to my account using FileZilla?
For themes, go to Appearance –> Themes. There you can see the themes you have installed. Try switching the one you’re currently using on your website.
7. Increase your PHP timeout values
PHP timeouts occur if a single PHP process runs for longer than the max_execution_time
or max_input_time
set in the PHP configuration on your server. If you run into a PHP timeout these values may need to be elevated.
You can check with your host what values are set on your server and if they can be increased as part of your current plan.
If you are a Host Duplex customer and still have questions, please open a ticket in the Host Duplex client portal.