Imagine that you have done a search and that the page proposed by Google sends you an unusual response: “HTTP error 502”
Frustrated, you will certainly go back to the SERPs to choose another page.
This is the typical scenario when we all face such an experience, which is not without consequences for SEO of the visited site.

Indeed, if enough users encounter the same problem on the page in question, you will agree with me that Google will simply downgrade or de-index it.
This is exactly why it is very important to make sure that your web pages are always available
Today, I’m going to tackle one of the failures that can cause your website to be unavailable: 502 errors
Glossary
In addition to explaining what the 502 or Bad Gateway code is, I will elaborate on its consequences, and then give you some tips on how to fix it
Ready to go? Let’s go !
Chapter 1: What is the 502 or Bad Gateway error?
When you visit a website, the browser on your device transfers a request to the server, which analyzes it and sends the desired results. The various responses that a server can provide when a request is submitted to it are designated by codes and divided into several categories.
Among these categories, we have the server errors designated by the code 5. It is among these errors that error 502 is located
Error 502 or Bad Gateway is a problem that can occur during the analysis of the server
The latter is then unable to transfer the request to the main server and this means that there was a communication problem with the server of the visited site
The website will then present a 502 error page on display

Source Openclassrooms
This error can be presented in various ways:
- Http Error 502-Bad Gateway;
- Error 502 ;
- Bad Gateway;
- 502 Service temporarily overloaded ;
- Gateway Error ;
- Bad Gateway the following error occured : [code=DNS_HOST_NOT_FOUND] The host name was not found during the DNS lookup. Contact your system administrator if the problem is not found by retrying the URL.

Source : dtechno-hacker
On Google, you will have an interface like this one:
Source : Kinsta
The display of these error messages is often accompanied by a closing of the window of active programs.
The real problem is the fact that it is not always easy to determine the causes of the 502 error.
Chapter 2: What are the origins of the 502 Bad Gateway error and what are its consequences?
In this chapter, I will explain the origins of the 502 error. I will also explain its consequences.
The origins of the 502 error are diverse. It can come from your devices as well as from the server of the visited site. It can be due to
2.1. A server failure
The 502 error or Bad Gateway can occur in case of a total failure of the visited server
A server failure can occur when an operating system or software stops working or is no longer displayed
Indeed, a server is a computing device, most often a computer that performs operations according to the requests sent by various clients.

Here are the various causes of server failure
2.1.1. An overload of the Web server or a DDos attack
Any web server has limits that should not be exceeded and when these limits are exceeded, the gateway may not respond to requests. It becomes slow and takes longer to load, especially if the requests sent are too numerous
The server can also, in extreme cases, crash and deliver a 502 or Bad Gateway code instead. This overload can be caused by too many visits to the site
It can also be caused by a DDos (Distributed Denial of Service) attack:

It is a computer attack that aims to cause the unavailability of a service in order to prevent its use. It can cause a blocking of access to the server or even block the distribution of email within a company.
2.1.3. Overheating of the Web server
This failure can also be caused by an overheating of the server
Indeed, servers need to be maintained:
- Cleaning
- Storage in an air-conditioned and secure place
- Protected from dust which is a source of overheating of the server
When they are badly maintained, they can overheat and thus cause a 502 error.
2.2. A browser error or a communication error
An extension in the browser of your device may be the cause of the 502 or Bad Gateway code. This means that this extension is corrupted. The connection between you and the target server may also have failed
It is also possible that your connection has become slow due to a problem with your Internet supply.
2.4. Incorrect PHP programming or a system error
Sometimes the website code may contain an error or you may have mistyped it. This prevents it from responding positively to the request.

It can also be a system error, but it is also possible that the web has removed the server because of illegal content
2.5. An infection of your computer
This is an extremely rare cause of 502 or Bad gateway error. In this case, your computer is most likely infected by a virus or malicious program that aims to corrupt your files and cause page malfunctions on your computer
To know if your computer is infected, observe these signs:
- Your computer becomes extremely slow to the point of crashing, freezing and requiring a reboot;
- The computer shuts down and restarts without your request;
- Your programs have trouble running or don’t run at all, or return strange error messages;
- Some devices are no longer accessible.
2.6. A corruption of the Windows registry or an accumulation of obsolete files
This corruption can be caused by changes you made to your operating system. It can be an installation as well as an uninstallation of programs
Also, if you have too many obsolete files on your computer it can affect your browser and cause a 502 or Bad Gateway error.
Chapter 3: What are the consequences of the 502 error?
If the 502 or Bad Gateway error is repeated too often, it can have harmful consequences on the functioning of the website
On the one hand, it seriously destroys the performance of the site, because a page that continually gives “Bad Gateway” results will no longer be referenced and it will be set aside by search engines
Indeed, search engines will not tolerate that their users encounter a site that is continuously unavailable
These types oferrors offer a poor user experience and we all know how patient we are when we browse the web

They will not be motivated to come back to the site even if the error is fixed. So it is urgent to fix it properly.
Chapter 4: How to fix the 502 Bad Gateway error?
Here, I will apply myself to guide you whether you are a site visitor or a Webmaster. This, through various steps so that you can get rid of the Bad Gateway error as soon as possible.
4.1 Tip to be followed by the Webmaster of a Web site that returns a Bad Gateway
If you are a webmaster and you have been reported that your site is displaying a 502 error code, first check that your website is working and accessible. Also check that your server is working properly
You can follow the tips for site visitors in the next section 4.2, as they may be helpful.
If so, then you can turn to your host, as the problem may well be with them
Contact your host so that they can check and clarify the issue for you. They may have already noticed the problem and are working to resolve it. But, in the meantime, you can follow the tips below
Tip 1: Install another DNS server or inspect your server logs
DNS stands for Domain Name System and it is used to translate internet domain names or identifiers into IP addresses.

The error may be independent of you and your web administrator and may instead be caused by your ISP due to a wrong entry in your DNS server
In this case, Install another DNS server
Also, inspect your server logs, as they will give you details about the status of your server. Check them thoroughly for any suspicious information.
Tip 2: Fix faulty firewalls to remedy Bad Gateway
Fix faulty firewall configurations: The firewall is the gatekeeper of your website, responsible for protecting it from unwanted visitors and various attacks
Your firewall configuration may be faulty and in this case it may consider a simple access request as an attack and reject it, causing the 502 Bad Gateway error.
Tip 3: Fix connection errors and disable plugins/extensions
To do this, you must first make sure that the web address was entered correctly and therefore does not contain any typos. Next, make sure that your internet connection is working properly.
It is possible that your plugins/extensions are corrupted. To disable them on Firefox, go to the menu then to help and click on restart and disabled modules
To disable them on WordPress, follow the detailed instructions in this article Twaino or follow the video
Tip 4: Disable the Content Delivery Network
The Content Delivery Network (CDN) is a collection of servers created to host and send copies of static or, if needed, dynamic content from your WordPress sites

It allows you to speed up the delivery of content to your site visitors. But it can happen that the CDN has a problem that causes the 502 or Bad Gateway error and the solution to solve this problem is disabling it
To do this: if you are using the CDN enabler extension that is used to link your content, you just need to disable it
4.2. Some tips for website visitors facing the 502 error
Tip 1: Check your system
Check that the error is not coming from your system by using Downforeveryoneorjustme :
It will allow you to know if you are the only one in this case and thus to locate the problem. If you are the only one in the case, then you will have to check your features and restart your browser
I advise you to restart it in safe mode, i.e. with the default settings.
Tip 2: Wait a while
The first thing to do when faced with such a situation is to be patient, because the error does not usually come from you, but rather from the server of the site to be visited
Therefore, it may be worthwhile to wait about fifteen minutes and then refresh the web page. Obviously, this is only valid if it is a page you know well and/or if there is important information on it.
If this doesn’t work:
Tip 3: Do a forced refresh of the web page
Perform a forced refresh of the page. A forced refresh, also known as a forced page refresh, is used to clear the browser’s cache in order to force it to load a more recent version of the page you are visiting
To do this, click SHIFT+F5 on Chrome or CTRL+F5 on Firefox.

Tip 4: Run a virus scan to deal with infections
Perform a virus and malware scan because the Bad Gateway error may be caused by an infection on your computer
You will need to scan your computer with an antivirus or diagnostic tool that will eventually generate a report containing the various viruses detected and the infected systems
You also have the option of performing an online scan to assess the scope of the infection and then send the report to an expert for guidance on what to do next

And if you find viruses or malware, you should isolate them from other programs until the computer is disinfected
Tip 5: Empty your browser’s cache and delete browser cookies
Consider clearing your browser’s cache to eliminate the error page in case your browser has stored it
To do this, press CTRL+SHIFT+SUPPR :

Deleting browser cookies could correct a 502 error
You don’t necessarily need to delete all your cookies, start by deleting the cookies from the site you are trying to access unsuccessfully by pressing the dotted line in the top right corner of the browser, then click on more tools and click on delete browsing data or press CTRL+SHIFT+SUPPR.
Tip 6: Restart your devices and change browsers
Restart all your connection devices, whether it is a computer, Wi-Fi router or modem
Then, change your browser. You can use Chrome, Firefox or Opera. If you are able to access the site with another browser, then install your browser again
You can also switch to private browsing by starting another private session
You will only have to close all the pre-existing tabs and open a new one in private browsing. On Google chrome switch to private browsing by pressing CTRL+SHIFT+L.

Tip 7: Clean your hard drive to fix a 502 error
Clean up your computer’s hard drive using hard drive cleaning software. This is an effective way to get rid of your corrupted files and kill two birds with one stone.
Clean your hard drive: After opening this PC, right click on the drive you want to clean and then select “Properties” which is in the last position on the menu

After that click on disk cleaning still in properties and select what you want to clean.
Once you have made your selection, click on OK and then on Yes for confirmation. Also, regularly delete obsolete files from your device.
Chapter 5: How to avoid the 502 or Bad Gateway error?
In this part, I will give you some practical and simple tips to apply to prevent possible 502 or Bad Gateways errors.
To avoid the 502 or Bad Gateway error :
5.1. Pay attention to the content of your website and to the non-corruption of your extensions
You must make sure that your website is always legal and complies with the law, the web and good morals. This is to avoid a possible removal of your website, which is a cause of 502 error or Bad Gateway.
You must also make sure that your extensions are not corrupted, because a corrupted extension can cause a 502 or Bad Gateway error
5.2. Keep your server running smoothly
You can keep your server running smoothly by
- Making sure it is not overloaded. To do this, you can limit the number of simultaneous requests to your site;
- Making sure it does not overheat. To do this, the server should be installed in a highly air-conditioned location and away from dusty debris.
5.3. Avoid viruses and malware by installing Antivirus software on your computer
Do regular scans of your system and also use effective firewall protection
Updating your system regularly will prevent your computer from being vulnerable to virus and malware attacks
In addition, you should be very careful with suspicious links and illegal files. Be careful about spam and unwanted messages

Spam is an e-mail message sent to you for advertising purposes without your consent. Some of them are intentionally infected in order to harm your device.
5.5. Be extra careful about the changes you make to your system
Uninstallations and reinstallations that you do on your Windows system may affect your site’s browsing operations and cause a 502 or Bad Gateway error. So be careful and attentive.
If the changes are not necessary for the proper functioning of your device, do not make them.
In summary
It can happen that the server encounters problems in the execution of its usual tasks. This is the case with the 502 error which, when it occurs, prevents you from accessing the content of the desired site, as is the case with the 404 errors.
But no more worries, you now have enough solutions to remedy it effectively. Follow the different tips I have listed in this article and you are sure to get rid of this failure.
Don’t neglect the various practices I’ve listed that help prevent a 502 or Bad Gateway error from occurring. Because prevention is better than cure!
See you soon!