DEV Community

Jaydip Parikh
Jaydip Parikh

Posted on

502 Bad Gateway - What is that & How to solve? How it affects your rankings?

502 Bad Gateway - this error message often causes confusion and frustration on the Internet because it prevents users from visiting the desired website. In this article, we will tell you exactly what “502 Bad Gateway” means, how the message affects your Google rankings and how you can resolve the causes of the error message.

What does " 502 Bad Gateway " mean?

Alt Text

The HTTP error code "502 Bad Gateway" indicates that the server is not getting a response from the requested URL because the gateway is not working. This means that no data exchange is possible and the desired website cannot be reached by the user.

A little digression: about gateways, proxies and servers

You may not be able to do much with our definition because you are not yet familiar with terms like “gateway”. No problem: we will take a short break.

Whenever you visit a website, your browser contacts a server. This sends back the requested content - together with an HTTP status code. If everything works as it should, you as a user cannot see this code. But if there is an error it will be displayed to you.

Data is generally transferred on the Internet via gateways, sometimes also referred to as proxies. Ultimately, this is just a server that stands between you and the main server with the required data and through which communication takes place.

Error codes from the 500 series usually originate from the server. " 502 Bad Gateway" means that the server could not be reached or that there is a defect in the communication chain.

This is how error 502 affects your SEO

If the “502 Bad Gateway” error only lasts a few minutes on your website, you don't have to worry about a major impact on your ranking. If a crawler should come by you during this time, it can also load your website from the cache.

It becomes problematic if the error message is not resolved for several hours. If users try to visit your website but only get a 502 message instead of the actual content, Google takes note of this. It is obvious to the search engine that there are difficulties on your part. In the worst case, it will cause your website to slide down in the search results.

Causes of "502 Bad Gateway"

The error message 502 may have quite different causes. However, it is difficult to find out what exactly it is. This is exactly what makes the notification so frustrating for users.

The following scenarios are conceivable:

  • The web server has failed or has been switched off.
  • The server is overloaded - for example, because an unusually large number of users want to access the same website at the same time.
  • Browser extensions interfere with communication.
  • There is an error in the PHP code on your website.
  • Firewalls disrupt communication.
  • The user is not connected to the internet.

502 Fix: You Can Do That

What measures are needed to ensure the error message "502 Bad Gateway" to fix depends on the causes. As I said, these are unfortunately not always easy to identify. Fortunately, it is often enough to wait for a little. In many cases, your hosting or internet provider will take care of the problem on its own.
Alt Text
Image Source

It is, therefore, best to visit the website again after a few minutes or hours. You only have to take action if the error message persists.

Go to another website

Try to go to another website. Do you also get a "502 Bad Gateway" message there? Then the problem may be on your side. First, check that your WiFi is working. If necessary, connect to the Internet using a LAN cable and test the affected side again.

Test who is affected

If the page is still not available, you can go to downforeveryoneorjustme.com to test whether the problem only affects you or all other Internet users. This already gives you an indication of where in the data chain you need to look for a solution.

Clear the cache and cookies

If you have the problem, clearing the cache and cookies can help. This ensures that the actual webpage is loaded and not a possibly broken cached version.

Check your browser

Go to the website in a different browser. If it works properly there, the problem may be in your first browser. Restart it once.

If the problem persists, open the browser in Safe Mode. All installed extensions are then overridden. Please visit the website again. If it can now be reached, the malfunction was probably caused by one of your browser plug-ins. Otherwise, you can try reinstalling the problematic browser.

Change the DNS server

In some cases, the reason for the " bad gateway " is with your Internet service provider. Then there is usually an incorrect entry on the DNS server.

Switch to another DNS server in your computer settings, for example, Google DNS and contact your Internet provider.

Contact your hosting provider

If the unreachable website is your own, you should contact your hosting provider. Often the mistake is on his side.

Check your website

If you have excluded problems with your hosting provider, check the PHP programming and the database of your website. In case of doubt, use an older backup of your site to correct the error.

Bypass "502 Bad Gateway"

If you are affected by error 502 not as a webmaster but as a user, there is a little trick you can use to avoid it.

Google stores caches from websites. Enter " cache: " and then enter the URL in the search field and this version will be displayed. However, it is not up-to-date and may therefore contain outdated information.

The error message “502 Bad Gateway” is without question annoying. Fortunately, in most cases, the problem will resolve itself within a few minutes. So next time, just get up and brew some tea. Only if you still cannot visit the website should you start troubleshooting?

Top comments (1)

Collapse
 
markfilan profile image
markfilan

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. The “proxy server” is a system or router that acts as a gateway between your computer and the internet.

How to fix?

Perform a hard-refresh in your browser. On Macs, this is done by pressing Cmd + Shift + R.

If you are surfing the Web and see this problem for all Web sites you try to visit, then either 1) your ISP has a major equipment failure/overload or 2) there is something wrong with your internal Internet connection e.g. your firewall is not functioning correctly. In the first case, only your ISP can help you. In the second case, you need to fix whatever it is that is preventing you reaching the Internet.

This problem is due to poor IP communication between back-end computers, possibly including the Web server at the site you are trying to visit. Before analysing this problem, you should clear your browser cache completely.

Finally, restart your computer/networking equipment. Some temporary issues with your computer and how it's connecting to your network could be causing 502 Bad gateway errors, especially if you're seeing the error on more than one website. In these cases, a restart would help.