When we surf the Internet and have to access websites, it is possible to find errors, and one of the most common is the 502 Bag Gateway Error. Today you will learn what it is and how to fix it.
Imagine that you are calmly surfing the Internet and when you access a website, you suddenly encounter a 502 Error. Although the causes may vary greatly in each case, the summary of this is that there was an error in the communication between the client and the server.
But, how to know the causes? Well, the first thing to know is that in an HTTP communication, the response codes are grouped by the number:
- 1xx – informative
- 2xx – Successful requests
- 3xx – Redirects between servers
- 4xx – Here are grouped the errors that concern the client.
- 5xx – In these codes are set the errors related to the server.
So, the first part is already done, and we know that 502 Bad Gateway error is an error related to the server where the website is hosted.
What is 502 Bad Gateway error?
According to the Internet Engineering Task Force (IETF):
The 502 (Bad Gateway) status code indicates that the server, while acting as a gateway or proxy, received an invalid response from an inbound server it accessed while attempting to fulfill the request.
In short, this error occurs when the server where the website is hosted receives an erroneous request from another server involved in the response.
Another way to say it is that the request was accepted, but the server prevented the fulfillment of the request.
What causes the 502 error?
As with most HTTP errors, the causes are variable, and there may even be several causes. However, after much testing worldwide, some of the most likely causes have been determined to be the following
- Server overload.
- Browser issues
- DNS issues
- Firewall blockages
- Incident with the local network
Of these possible causes, one of the most frequent is server overload. This happens when unexpectedly the server has to process many requests on the website.
Another quite common problem is with the DNS. This happens when a change in these servers happens over the Internet, it is possible that the redirection has not worked properly at that moment and causes the error.
The other causes, a little less probable, are oriented to very specific issues instantly of time. However, in the case of the Firewall, it is good to keep an eye on it as well as the proxy options in case you have one.
How to fix the 502 Bad Gateway error?
Now that you know something about the 502 Bad Gateway error, you may already have some solutions that you should try to fix it.
Refresh the web page
Firstly, sometimes it is an error that lasts a very short time. So, the first way to fix the error is to have a little patience and just reload the page after a few minutes.
Occasionally, this will work and it is so easy.
Clear your browser’s cache
Although this is not a 100% effective solution, many times the problem is in your web browser. To make sure that all is well with it, you can then clear the browser cache.
The process varies according to the web browser used. In Firefox chaos you just need to access the options and in the Privacy and security section clear the data.
This process is a way to solve the error.
Temporarily, you can also use the incognito mode of Firefox or Chrome to have a private session and test if it is a browser issue.
Flush DNS or change DNS server
The 502 error can also be caused by DNS issues. So, you can change the DNS server at the router or system level.
For this, there are many tutorials for each router or for each system. But this is one possible solution.
Another possible solution based on DNS is to clear your cache. On Ubuntu, it is simple, as we indicated in the post.
If the problem persists….
If none of the above has helped, then the issue is more serious. A good idea is to contact the webmaster directly to tell him about the difficulty.
Another thing to try is to call your ISP to let them know, and they can restart your connection with another IP address to have a possible solution.
In case you own the website, and it is made with WordPress, then a possible solution is to disable some plugins or check the CMS configuration.
Although the 502 error can happen at any time, it is certain that there are possible solutions, and it is unlikely to be encountered for a long time.