Have you ever met the 502 error when running your website? This time, we’d like to introduce this annoying error and tell you how to fix the error 502 bad gateway in WordPress effectively. Actually, this is a signal to indicate the fact that some pages, process, scripts and queries have taken the too much long time to complete, so as to be rejected by the web server.
Actually, when running a WordPress site, you may meet many errors like error 400, error 404 and more. But the bad gateway one is one of the most popular errors you may encounter. After all, this HTTP error not only happens on your WordPress site, but also on some other popular services such as Twitter, Gmail and CloudFlare. In this case, it can easily influence the running of your site and you’d better deal with this error as soon as you can.
What is 502 Bad Gateway?
502 Bad Gateway, also known as HTTP 502 error, is included in the HTTP response status codes. The server is used as a gateway or a proxy to serve the clients and meet all the URL requests. When it receives an invalid response from the upstream server, the 502 Bad Gateway happens. At that time, a pop-up page reading “502 Bad Gateway” will turn up before your eyes.
Actually, it doesn’t mean that the upstream server gets into trouble. The cause of this issue is that the upstream server and the gateway do not reach an agreement on the protocol when exchanging data.
The 502 Error Variations
Due to the differences of multiple browsers, OS system and server machines, this HTTP error can be presented in plenty of different ways. However, they indicate the same meaning. In the following, we have listed some common variations you may check on the web.
- HTTP Error 502 – Bad Gateway
- 502 Proxy Error
- Error 502
- 502 Bad Gateway
- HTTP 502
- 502 Service Temporarily Overloaded.
Common Reasons that Lead to This Error
Actually, this error generally happens when there is the bad communication between your web servers.
- Your server machine is overloaded.
- Browser caching is turning up.
- There are some issues related to your DNS.
- There are some problems with your network and router.
- Your upstream servers are down from online.
- There are some buggy PHP scripts in your WordPress site.
How to Fix 502 Bad Gateway?
Reload Web Pages
If this issue is attributed to the bad IP connection of the back-end computers and temporarily existed, you need to clear browser caching at first. Besides, you can try to press the F5 or click the refresh button to reload the web page. It might help you work the issue out. If this method doesn’t work, you can try it later.
Check Network Connections
When you surf on the Internet and suffer this problem on all the web pages you are visiting, there may be a major failure occurred on the Internet Service Provider (ISP) or some issues come out on your network connections.
At this point, you need to inform your ISP and tell them what happened on your computer. The professional technicians will take measures to solve this problem. If it is due to the network connections, you should check the network at first and restart the computer to turn back to the normal networking status.
Reset the Default Gateway
If the methods mentioned above cannot make a difference, you can try to reset the IP address on your computer. Firstly, you need to click Start > Control Panel and search the “adapter” in the search bar. Enter the Network and Sharing Center > View Network Connections.
Secondly, you need to right-click the network that you are utilizing and select “properties”. In the networking lab, choose the “Internet Protocol Version 4” and click the “Properties”.
Thirdly, you can change the IP address in the blank called Default Gateway. For the office network, you can get the IP address from the administrator. While for the family network, it is the IP address of your router. Lastly, you just need to save it and finish the whole process.
Clear the Cache of Your Browsers
It is possible that you have tried different browsers to access your site. And to your surprise, the 502 bad gateway disappears in a new browser but comes back again when you use your old one. If so, you should clear the cache of your old browser.
It is true that the caching system can ensure the faster accessing and loading speed of a webpage or a site. However, some aggressive caching solutions may save the error 502 to your browsers so as to repeat the annoying error information.
Fix the DND Issue
It is possible that this issue is due to the DNS settings, especially when your domain name is not resolving the right IP address. In this case, when you migrate your site to a new web host, you have to wait until the full propagation is finished.
Contact Your Hosting Provider
Sometimes, the error 502 is caused by your web host, especially the shared web hosting company. Generally, if your scripts, queries and any others take too long to respond, the hosting provider will kill or cancel them so they will not impact other users. And this is how the error 502 happens.
In this case, you should contact the technical support team of your hosting provider and ask for the help.
Check the Plugins and Themes Installed into Your Site
You cannot confirm that there is no buggy code into your installed themes and plugins, especially when you are just the common webmasters but not the developers. In this case, you should detect whether the 502 bad gateway is caused by your template and plugins. To do this, you just need to deactivate them to see whether the error disappears.
There are two ways to do so. If you can access the website admin, the Plugins and Themes sections allow you to achieve the deactivation easily. If not, you need to leverage the FTP client to rename the plugins folder and the themes folder.