Fixing 502 Bad Gateway – When you are browsing on the internet, you may have experienced several errors such as “Error establishing a database connection” or “HTTP Error 500”. One of the most common types of website errors is “HTTP 502 Bad Gateway Error”.
This error doesn’t only occur on WordPress websites, but sometimes, it also occurs on Gmail, Twitter, and Cloudflare. This time, Writer River will discuss “What is HTTP 502 Bad Gateway Error?” and the most effective ways of fixing error 502 bad gateway.
What is the meaning of 502 Bad Gateway Error?
Before we talk about troubleshooting 502 bad gateway error, first, I will explain what a 502 Bad Gateway Error is. Every time you visit a website, your browser will send a request to the web server. Then the web server will receive and process the request. After that, the web server will send the requested resource back together with the HTTP header & HTTP status code.
Usually, the HTTP status code won’t be visible unless something is wrong. The HTTP status code works as a notification if something doesn’t work as it supposed to. The number you see in the Error Code is a code that can help you find a way to solve the problem.
One of the most commonly seen error codes is 500 status error codes (for example 500, 501, 502, 503, 504, etc.). Each number has different meanings. These codes indicate received user’s request, but the server didn’t allow the request to be processed.
502 Bad Gateway is an error that indicates the server works as a gateway or proxy receives an invalid response from the inbound server.
Kinds of 502 Bad Gateway Errors
Within numerous browsers, web servers, and operating systems (OS) these days, 502 Bad Gateway Error can appear with several different looks. But actually, they all have the same meaning. Kinds of 502 bad gateway errors that you might see while browsing on the internet are:
- 502 Bad Gateway
- HTTP Error 502 – Bad Gateway
- 502 Proxy Error
- Error 502
- HTTP 502
- 502 Service Temporarily Overloaded
- That’s an error. The server encountered a temporary error and could not complete your request. Please try again in 30 seconds. That’s all we know.
- 502 Server Error: The server encountered a temporary error and could not complete your request.
- 502 Server Error
- 502 – Web server received an invalid response while acting as a gateway or proxy server. There is a problem with the page you are looking for, and it cannot be displayed. When the web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.
- Nothing appears, just blank white screen
There are also websites that have their own page to display 502 Bad Gateway error. Usually, their custom web page is user-friendly.
How 502 Bad Gateway Error Affects SEO
In contrast to the “Briefly unavailable for scheduled maintenance. Check back in a minute” error, which is used for maintenance mode on WordPress and tells Google to check the website again later, 502 Bad Gateway error directly aff
If your website is down for 10 minutes and crawled by Google consistently, usually, the Google will crawl the cache of the page. But if your website is down for hours, let’s say 6 hours or more, then Google might see the 502 Bad Gateway error on your website. This might drop your website ranking on Google. You don’t want that to be happened right?
Fixing 502 Bad Gateway Error Quickly
The 502 Bad Gateway error is usually related to network or server issue. But, this error can also be caused by the client-side issue. So, I will tell you about some effective ways of fixing 502 Bad Gateway error from the server side and client side.
Reload the Page and Clear Web Browser’s Cache
The first step you should try when you get a 502 bad gateway error is waiting for at least one minute & reload the website page. There’s a possibility that the error occurred because the server is overload and soon, the website will be normal again.
When you’re waiting, you can also try opening another website in order to see if the issue only occurs on the website or not. In addition, you can also check DownForEveryoneorJustMe.com, it will tell you if the website is actually down or there is an issue on the client side.
If you have reloaded the website page and you still see this error, you can also try to clear the browser cache. You must understand how to clear the browser cache step by step on different browsers.
The 502 Bad Gateway Error can also occur due to an issue with DNS (Domain Name System). For example, the domain doesn’t resolve the correct IP Address. If you have just migrated your WordPress website to a new hosting platform, you need to wait for at least 24 hours to ensure that the migration runs successfully. This depends on the TTL value of your DNS.
You can also try clearing your local DNS cache. The way the local DNS cache works is similar to the browser cache. In Windows, you only need to open a command prompt and enter the following code:
If that works, you will get a message “Successfully flushed the DNS Resolver Cache”, as shown below:
For Mac users, you can enter the following code into your Mac terminal:
After that, you won’t see any messages afterward either it was succeeded or not. You can also temporarily change your DNS server. By default, the DNS server will be automatically selected by your ISP or Internet Service Provider. But you can temporarily change the DNS server to the public DNS server.
One of the main reasons why you get a 502 Bad Gateway error message is because of the website hosting issue. Sometimes queries, scripts, or requests process will take longer than usual, and it might be canceled or turned off by the server. Most website hosting (especially shared hosting) implements a “Kill Script” system. Basically, Kill Script is a system where they will stop requests after specific times so this request won’t affect other hosting users.
Disable The CDN (Content Delivery Network) For A Moment
A 502 Bad Gateway error can also occur due to a problem with the CDN (Content Delivery Network). If you use a third-party CDN provider, one way to fix 502 Bad Gateway errors quickly is by disabling the CDN for a moment. You can log in to your website via SFTP and rename the plugin folder to cdn-enable_old. This way, you can temporarily turn off the CDN connection, fixing 502 bad gateway issue, and enable it later.
Extra Firewall or DDoS Attack Protection from Web Hosting Provider
Besides some of the causes above, the 502 Bad Gateway error can also occur if the web hosting service provider you are using provide DDoS attack protection and proxy services whose owned by Cloudflare because they do have extra firewalls. Error 502 often appears on the free Cloudflare service. Unfortunately, because Cloudflare is a full proxy service, it’s not easy for you to turn it off.
Check Your WordPress Website’s Plugins and Themes
In most cases, the reason for the scripts and queries cancellation by the server is because of bad code on your WordPress website. This bad code can come up from Plugins or Third Party Themes. In addition, there are also some cases where there is a misconfiguration of the plugin caching which eventually causes 502 bad gateway error.
Deactivate Plugins on WordPress
The most effective way you can do to fix this issue is to disable the plugin or change the theme of your website. Remember, you won’t lose important data on your website by just deactivating the plugin. If you still have the access of admin panel, the way to disable the plugin is to go to the Plugins option and then click Deactivate from the Bulk Actions menu. That way, all plugins on your WordPress website will automatically be deactivated.
If this can fix the 502 Bad Gateway error, then the next step is to find out which plugin caused this error, by trying to activate the plugin one by one while reloading your website after each plugin activation. When you see the message 502 bad gateway error appears, it means you have found the plugin which causes error 502. You can ask for help to plugin developers to solve the issue or post a support ticket in the WordPress repository.
Deactivate WordPress Plugins through FTP
If you can’t access your admin panel, go to your FTP (File Transfer Protocol) and rename your plugin folder to plugins_old. Then, try checking the website again. If this method works, it means you only have to find out which plugin causes the error, by renaming the plugin folder one by one while reloading the website to see which plugins are problematic. It’s kind of the same thing as before.
That’s it, fellas! You see, there are some effective ways of fixing 502 bad gateway error. Usually, this error occurs not because of issues on the client side but rather related to issues on hosting and websites, the bad code from third-party plugins and themes, or not-optimized queries.
If you still have questions or want to share other effective