As you are reading this post and so you are either a WordPress user or while accessing the WordPress website, you have encountered this 502 bad gateway error. No matter what the reason behind is looking for the 502 error solution, in this detailed guide, we will talk about all the aspect of the error, it’s root and the resolution. But before going into the details, let’s check what 502 error is?
What is 502 bad gateway error?
502 error is basically an HTTP error code which you will receive when one server on the internet is not receiving the response from the other servers. This error doesn’t depend on how your server is setup and can vary with the server, operating system, and browser.
Also, different browsers show this 502 error in a different way. Here are few different variants of this 502 error which you may encounter with other browsers.
- 502 Bad Gateway
- 502 Service Temporarily Overloaded
- Error 502
- Temporary Error (502)
- 502 Proxy Error
- 502 Server Error: The server encountered a temporary error and could not complete your request
- HTTP 502
- That’s an error
- Bad Gateway: The proxy server received an invalid response from an upstream server
- HTTP Error 502 – Bad Gateway
All above shown error codes are just the variants of the 502 bad error gateway code and the process to resolve these will be the same. According, to the leading free web hosting company 000webhost, many top sites like Twitter, Google, etc. have also experienced such kind of errors. They have also published a detailed post on the same which you may also check.
What causes this 502 bad gateway error?
There can be many reasons behind this 502 error which you need to understand in order to get and resolve all the variants of the 502 error easily.
A bad gateway error is often caused by the communication happened between the two online servers over which you don’t have any control. This can be even due to some temporary issue with the browsers also. And so, you are advised to recheck the issue to ensure that it is not temporary. Here is a simple image is shown to understand the 502 error in easy terms.
Here are some of the major reasons due to which you may get this 502 error messages-
#1 Domain name not resolvable
Here either your domain name is not pointing to the correct IP or doesn’t resolve to any IP. Also, if you have recently changed the DNS for the domain, you may need to wait for some time in order to ensure that it has been configured correctly. Meanwhile, you may get that 502 error message. In order to avoid the wait time, while changing the DNS, you can select minimum TTL so that changes will affect from immediate notice.
Here I mean to say that the if the source server will be down then also you may get this 502 error. And most of the time this is the reason behind this error. So, either your source server is down or having some intermittent issue. Make sure before going into deep or contacting the support team, you are refreshing the site and ensuring it is reproducible. Especially, if your system is in the cluster then make sure all the servers associated with it is working fine.
#3 Firewall block issue
A firewall may block the communication between the production server and edge server and so the request may not reach the destination, and this may create the issue. And so make sure you are getting the security things done correctly.
Also read: Smart Ways to Access Blocked Websites
#4 Check the plugins
If you are using any security plugin then also it can cause the issue. The things will be similar to the firewall issue and it may block certain communication which may cause the issue.
So, no matter what the reason behind this is, the below solution is definitely going to help you while you recover from the 502 error for the bad gateway.
Fixing the 502 bad gateway error
Here are some of the methods using which you can easily resolve this 502 bad gateway error.
#1 Try reloading the website URL through which you have received the error. Sometime this will be just a temporary error and refresh the URL will resolve the problem for you.
#2 If the 1st option is not resolving your query, you may want to close all the active sessions of the browsers open at your end and want to start a new one and open the site. Usually, this 502 error will be due to the network problem and it may be related to the browser issue as well. So, close all and try reopening it. If this still doesn’t resolve your issue, keep on going with the other solutions.
#3 Clear cache & Delete cookies: This can be your next step to ensure there is no blockage from the browser point of view. If your temporary cache has once crawled the error, it may persist further as well. And so, make sure you are clearing the cache and also deleting the cookies. These steps will ensure a fresh and new window for all.
#4 Restating the network equipment such as WiFi router or network switch can also do the magic for you. If the 502 error was due to some network intermittent issue, then restarting will definitely resolve it for you.
#5 Disabling the CDN some time can also work for you. And so, if the above steps have not worked for you, you may want to disable the CDN for some time and check if this is working. Especially if you are working with the free CDN then doing this step is necessary.
#6 If still, this has not worked for you then you should check the DNS and local DNS. Make sure these are working fine and configured properly. You may also need to check and confirm the other WordPress plugins installed on the website. Try uninstalling it and start installing one by one to ensure that the issue is not due to the plugins.
These were all about the identifying and fixing 502 bad gateway error. I hope you got a clear idea behind this popular WP error and steps to resolve it.