Every time the site is opened, the browser sends a lot of requests to other web servers. The servers then process these requests and return the HTTP response code along with the processing result.
Typically, the HTTP response code is not displayed until there is a problem. Thus, the servers inform each other and the end user what exactly went wrong.
What does error 502 mean?
The HTTP response code, which starts with the number ” 5 ” refers to the errors associated with the loss of communication between the servers. The exact cause of the occurrence in most cases is on the server side.
Receiving error 502 bad gateway error means that the source server sent the wrong response to another server that acts as a gateway or proxy.
Since all requests to the web are redirected through multiple gateways, it can be very difficult to determine the exact location where the difficulties occurred.
However, there are basic steps for identifying, by performing which you can fix the error.
Error 502 bad gateway can also occur in different forms and types. Here are some options for its appearance:
Temporary Error (502)
Error 502
HTTP Error 502 Bad Gateway
502 Server Error: The server encountered a temporary error and could not complete your request
502 - Web server received an invalid response while acting as a gateway or proxy server
HTTP 502
502 Service Temporarily Overloaded
502 Bad Gateway Nginx
How to fix 502 bad gateway error
Since error 502 bad gateway is usually associated with server-side problems, it can occur because of an incorrect configuration or a problem with the client side.
We will look at the steps for finding a solution in both cases. W
hile some solutions are WordPress-oriented, most of them can be applied to any site. Let’s proceed to the steps to find the cause and solve the error 502:
1. Refresh the page
The first solution will be very simple. Wait for about a minute or two and refresh the page on which you were. In most cases, a temporary error and a simple page refresh will achieve the goal.
It should be noted that you can also check whether the site is working by using the online tool.
2. Clear your browser’s cache
If the error remains, there is an option that some cached item leads to it. Then clearing the browser’s cache is a good approach in identifying the causes of the 502 bad gateway error.
3. Try a different browser
Check the connection using a different browser or incognito mode – this is also a great idea.
This will allow you to exclude the cause of the error associated with the browser.
4. Clear the DNS cache
Error 502 can also occur for a reason related to DNS, such as an incorrect IP address value in the cache. In this case, resetting the DNS cache is another solution that you can try.
You can also temporarily switch your DNS server to Google Public DNS by default .
5. Check on another device
If none of the above could help fix error 502, check the connection on another computer or mobile device, preferably connected to another network.
This is the final step, which will determine where the error is on the side of your car or somewhere else.
6. Check the error log
If error 502 bad gateway occurred after a specific change or update, it’s possible that the reason lies inside the site itself. The best approach is to check the error log to find hints.
In WordPress, you can enable error logging by adding such lines to the wp-config.php file :
define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', false );
All created entries will be displayed in the wp-contents / debug.log file .
7. Check the plugins
It is also important to check your plug-ins and extensions.
Problems with caching plugins can result in a 502 bad gateway error. A simple way to check if the problem is in the plugin is not to disconnect them all for a long time.
To do this, go to the wp-content directory and rename the plugins directory .
If your site has earned after disabling all the plug-ins, you can rename the directory back to the plugins and go into it. Then try to disable plug-ins one by one to check which one is causing the error.
8. Check the CDN
Other cause of the 502 bad gateway error can be CDN networks or DDoS prevention services.
One of the great illustrations can be CloudFlare, where error 502 bad gateway is in two different versions, depending on the reason.
This page indicates that there is a problem on the CloudFlare side and you need to contact their support service to resolve it. Alternatively, you can choose to disable CloudFlare, but keep in mind that a DNS update can take several hours.
However, if you see this error, it means that the error is on the side of your hosting provider.
9. Contact your hosting provider
If nothing has helped to correct the error 502 bad gateway from the above, then it’s best to contact support.
Describing the situation, try to mention all the steps taken to eliminate that you have taken.
Provide as much information as possible and you will definitely be helped!
Conclusions
In this manual, we learned what a 502 bad gateway error is and what approaches exist to solve it.
If you have additional tips, tricks or solutions, feel free to share them with us in the comments below!