502 Bad Gateway Error: In the network, everything does not always work well, and it is that from time to time an HTTP status code is received instead of the page that was searched, which indicates that something has failed.
If, as an Internet user, you have received an error code of class 5XX, in most cases the cause of it is not on your system or on your Internet connection, but on the server of the website itself. In the case of error 502, however, there may also be something wrong with your configuration, which can be presumed if the code appears when trying to open any page.
In this guide, we give you some tips with which to find out the source of the 502 Bad Gateway Error and what you can do as a user to see the contents of the website. Are you the manager of an affected page? In that case, you can also use the indications we offer to locate errors.
What does Bad Gateway mean?
The HTTP Internet protocol delivers status codes in response to requests to the server. The most common code, but not visible to users, is 200 – OK, which indicates that everything worked correctly.
The visits of the web pages only see the requested content, something that differs greatly from when the error messages appear. While in the codes of class 4XX the error lies on the client-side, in the codes between numbers 500 and 511 the fault of the negative results lies with the server.
The status codes also report the place where the error occurred, at least to those users who know what each of the codes means.
Error 502 Bad Gateway receives different names, including “Bad Gateway”, ” 502 Bad Gateway Nginx“, “502 Bad Gateway Apache” or “502 Bad Gateway registered endpoint failed to handle the request”.
In addition to the known 404 error, (“Page not found”), Bad Gateway errors are some of the most common error messages when surfing the Internet. These appear when the server with which the main server is accessed cannot forward the request. In such circumstances, the first server only acts as a proxy, gateway or gateway.
In principle, all requests on the Internet are made through gateways. So, this error message is so frustrating because the place in the request chain where the error occurred is not always evident.
What are the causes of the 502 Bad Gateway error?
In most cases, the 502 Bad Gateway takes place on the server-side and Internet users cannot remedy it, although it is also possible that the browser reports a 502 error even if it does not exist or that no connection can be established More from your network. The appearance of the detested HTTP 502 code can have the following causes:
- Web server crash: the gateway gets a negative result when the destination server fails completely, which can only be due to a system failure. Less frequent but plausible is the disconnection without warning of the server when, for example, its content violates the law.
- Web server overload: when a web server reaches its limits it can no longer respond to requests, so the gateway delivers the Bad Gateway 502 status code. The causes can be either a sudden huge interest in the page or a DDoS attack. With it, the attackers try to overload the capacity of the server with the help of a botnet in order to cause it to fall.
- PHP programming contains errors: sometimes there may be errors in the code of the web page, so it is possible that it is not answered as it is due to some requests and that these give negative results.
- Communication error: firewalls can be responsible for errors on both the server and client-side when transmitting requests.
- Browser error: browser extensions also cause errors when viewing web pages and can generate error 502.
How to fix the 502 Bad Gateway error:
Both users and web administrators have the possibility of taking action against the 502 bad gateway. In many cases, it is only necessary to wait, because the error often takes place outside the area of influence itself and its solution lies in the hands of Internet providers (ISP, Internet Service Provider) or web server hosting. In case the source of the error is on your page, you should look for its causes.
That said, we will move on once to the possible solutions that you can apply if error 502 appears on a website that you are interested in accessing. From easier to more complex, here you have them!
Method 1: Reload the page:
It is possible that the server that hosts the web is overloaded for some reason (for example, by a peak of requests). Press Ctrl + F5 or the Refresh button to reload the page and check if you can already access. If not, close all browser tabs and open it again, wait a minute and try to access the web again.
Still nothing? Then, try using a different browser. If you can access normally, it is best to uninstall the browser that failed and reinstall it again. Now, if the fault persists even from another browser, go to the next method to fix error 502.
Method 2: Clear the browser cache:
Sometimes, your browser will simply be remembered that before that website resulted in an error. To ensure that the error you are receiving is current and not a mere “reminder” and that your browser is not storing outdated or corrupt information, clear your browser’s cache and cookies. If the problem was this, by deleting the cached files and reloading the page, error 502 will be fixed and you will be able to access the web.
Method 3: Disable the CDN:
The CDN or content delivery networks ( Content Delivery Networks ) serve to improve the loading speed of websites. However, sometimes they can cause the 502 Bad Gateway error because they use additional firewalls. To check if this is your case, temporarily deactivate your CDN and check if the error has disappeared.
An example of the most used CDNs is Cloudflare, as it has one of the best free plans. If it is the network you use, it will be very easy to know if it is the culprit of error 502 because on your screen you will see something like this:
Method 4: In WordPress, check plugins and theme:
It is possible that some of the plugins or theme of your WordPress contain defective code (or are incorrectly configured) and, as a consequence, are triggering gateway errors that should not be occurring.
Try deactivating the plugins one by one, checking in each case if the error 502 disappears. If you are using a cache plugin, start with that: it is your main suspect.
To deactivate the plugins, you will not have any difficulty as long as you have access to the WordPress dashboard and the Plugins section. Instead, if you cannot enter the administration area, follow these steps:
- Enter the wp-content folder and change the name of the Plugins directory to “Plugins-disable”. What you will cause is that all plugins are deactivated at the same time. If the web works and no longer gives error 502, it is clear that one of the plugins is to blame for the error.
- Change the name of the folder again, from “Plugins-deactivate” to “Plugins” and enter it.
- Deactivate the plugins one by one. To do this, change the name of each plugin, for example, change “jetpack” to “jetpack-disable”. After each change, check if error 502 has disappeared or if you can still see it.
At some point, the plugin you deactivate will be the culprit of error 502 and your website will be correctly active again. Leave the plugin deactivated and find out what has happened: is it incorrectly configured ? has it not been updated for a long time? You may have to look for an alternative complement.
Method 5: Check the error logs:
If you have made any changes or updates to your website recently, it is possible that error 502 is a consequence of it. To check if this is the case, the simplest is to check the error log. The location of the log varies depending on the web hosting and the control panel that you have hired, so I cannot give you specific instructions. However, you can create a phpinfo.php file that includes this piece of code:
Put it in your root folder and access it from your browser using the URL www.yourdomain.com/phpinfo.php. Look for the error_log text and there you will have the path where your error log is located.
If you use cPanel, you will find the error_log file if you follow these steps:
- Access the control panel, scroll down to the Files section and click on the File Manager.
- On the left side, click on the public_html folder and inside, you will find the error_log file.
- eye! If you were accessing a subfolder of your page (for example, “yourdomain.com/folder”), the logs will be in the yourdomain.com / folder ” ), the logs will be in the directorypublic_html / folder directory.
This file will contain, organized by seniority, all errors that have occurred on your website, including the reason for the error and the line on which it occurred.
If you use WordPress, you can enable error logging by adding this code to the wp-config file:
In general, the generated entries are usually stored in the wp-content directory.
Method 6: Restart backend services:
This is a bit technical, I’ll let you know! If you use a web server configuration in which you invoke a PHP daemon – such as PHP-fpm or PHP-lap – it is very possible that your service is down or does not respond. This can also happen if you use a reverse proxy type configuration; For example, you have an Nginx web server that routes requests to an Apache that is very busy or, in the worst case, has been broken.
In these cases, it is imperative to restart the final service (Apache, Php-fpm, etc.) because if it is down it will not respond to your proxy and, if your proxy receives no response, it will return a 502, which is the most literal example of this error.
|Note: Remember to check that there is no firewall rule that prevents your proxy from communicating with Apache or PHP! |
It is easy to think that the firewall is only for external connections, but those that are internal can also be affected.
Resolving an error when you are not sure what is causing it is one of the most frustrating processes that a webmaster has to deal with. Therefore, a basic understanding of the specific error will advance you greatly in the course of diagnosis. As you can see in this article, there are several possible ways to solve the 502 Bad Gateway error.
Have you understood what error 502 consists of and the possible solutions that can be applied? If you have any questions, leave a comment and I will try to help you. Do you think I forgot something or do you have more ideas to diagnose and solve a 502 error? Tell me
- Barkskins Season 2 Release Date On Nat Geo? Premiere Date
- Sweet Whirl to launch forthcoming album with livestream performances
- Wuhan wet market the ‘victim’ in coronavirus outbreak, says China health expert
- WATCH Doja Cat’s Apology On Chat Room Anti-Blackness, Hating Her Hair, Racist Lyrics…
- When Does Diesel Brothers: Diesel Nation Season 2 Release? Premiere Date
We hope you are all the success.