502 Bad gateway WordPress
On WordPress, you never know what error can be encountered. These are quite confusing and hard to solve for a person who is not familiar with the technology. The most common mistakes made by WordPress users are the blank screen and the inability to connect to a database. Both are easy to repair. Another error is the Bad Gateway 502 error, and people get it so often that it seems good to create a guide on how to fix it.
The 502 Bad Gateway error can be difficult to solve for a multitude of reasons. First, you must find the source of the problem. Then you need to change the settings to get your website up and running again. All WordPress users are not used to solving this problem. This guide will be useful. Before you fix error 502, you need to understand why this is happening.
The problem of the wrong gateway has many reasons. Some of the most common are:
- Bugs in the site database
- Server unavailable or expired
- Missions with the reverse proxy server
- Problems in PHP codes, which are usually caused by third-party software, including plugins and themes
- Server overload due to massive number of visitors to the site or a DDoS attack
- Firewall blocking requests
Although the faulty gateway error 502 typically relates to server-side issues, it can also be caused by configuration errors or client side issues. Therefore, we will review the common troubleshooting steps keeping in mind both causes. Some solutions are focused on WordPress, but most of them can be applied to any website. Without further ado, let's take a look at the steps to solve the 502 gateway error problem.:
Refresh the Page
The first solution is quite simple. Wait a minute or two and refresh the page you are on. In many cases, the error is temporary and a simple page refresh will do the trick. In the meantime, you can also check if the website is down using an online tool.
Clear Browser Cache
If the error persists, some cached item may cause it. Thus, clearing the browser cache is a good approach when troubleshooting the faulty gateway error 502.
Try a Different Browser
Checking the connection using a different browser or in incognito mode is also a good idea. This will eliminate the possibility that the error will appear due to a browser issue.
Incorrect gateway error 502 may also appear because of DNS issues, such as poorly cached IP address values. In such cases, emptying the DNS is another thing you can try. Here is a tutorial on how to empty the DNS on Windows, Mac and Linux.
You can also try to temporarily change your default DNS server to public DNS.
Test on Another Device
If none of the above solutions resolves the invalid gateway error 502, test the connection on another computer or mobile device, preferably connected to another network. This is the last step in determining whether the error is related to your computer or if the problem is elsewhere.
- Check Error Log
If the faulty 502 gateway error has occurred after some change or update, it is possible that the fault is in the website itself. The best approach is to check your error log for any advice.
In WordPress, you can enable error logging by adding the following lines in wp-config.php:
define ('WP_DEBUG', true);
define ('WP_DEBUG_LOG', true);
define ('WP_DEBUG_DISPLAY', false);
All generated entries will appear in the wp-contents / debug.log file.
It is also important to check your plugins and extensions. Plugin caching problems can often lead to an incorrect 502 gateway error. A simple way to check if plugins are involved is to disable them all for a short time. To do this, go to the wp-content directory and rename the plugins directory.
If the website starts working after you turn off all plug-ins, you can rename the folder into plug-ins and enter it. Then, try to disable the plugins one by one to determine which one caused the error in the first place.
Another cause of incorrect gateway error 502 may be CDNs or DDoS mitigation services. CloudFlare is a notable example because the wrong gateway 502 can come in two different forms, depending on the problem.