How to Fix 502 Bad Gateway Error?

Would you like to know how to fix the 502 bad gateway error? Usually, the 502 Bad Gateway error is a result of a network failure between two servers on the internet, which means that the problem has nothing to do with your computer or internet connection.

In general, 502 Bad Gateway errors are completely independent of your particular configuration, meaning that you may see one in any browser, running any operating system, or using any device.

This article will discuss what a 502 Bad Gateway Error is, what are its causes, its variations, its impact on the SEO, and how to fix it with various methods.

What Is a 502 Bad Gateway Error?

If you receive a 502 Bad Gateway error message, this means that the server you are trying to connect to has received an invalid response.

An HTTP request is sent by your browser to the server when accessing a URL. However, in this case, the request was invalid and returned an HTTP 502 status code. The HTTP status codes are a means by which browsers and servers communicate with each other.

A URL is accessed through a browser by sending an HTTP request to the server of the website you are visiting. After requesting the resources, the server returns a status code and the requested resources.

The HTTP status codes can be categorized into five categories: 1xx – informational, 2xx – success, 3xx – redirection, 4xx – client error, and 5xx – server error.

Generally, status codes starting with the digit 5 indicate errors that occur when there is a network breakdown or a communication problem between web servers.

There are also 5xx status codes such as 500 Internal Server Error, 501 Not Implemented, 503 Service Unavailable, and 504 Gateway Timeout.

In most cases, the cause of the error lies within the server itself, even though the exact reasons for each error may vary.

What Causes a 502 Bad Gateway Error?

You should first examine the possible factors that may be causing the Gateway error before attempting to fix it. These are some of them:

Unresolved Domain Name

Usually, this occurs when a domain name fails to resolve to the correct IP address. If your domain name has recently been migrated to a different host DNS server, it may take up to 24 hours for the changes to become fully propagated and effective.

Origin Server Overload

The origin server may become overloaded and crash whenever it runs out of resources, resulting in an HTTP 502 error message.

It has been shown that sudden spikes in traffic, a lack of memory, and software timeouts are some of the common causes of server overload.

Browser Errors

Browsers can sometimes display a 502 coding error even though there is no problem with the server or network.

If this happens, the error may be caused by faulty browser extensions such as ad blockers, outdated browser versions, or corrupted files in your browser’s cache.

Home-network Equipment Issues

Your network equipment is likely experiencing a temporary problem if you experience HTTP 502 errors across more than one website or browser.

Firewall Blocks

Firewalls prevent suspicious traffic from entering your website. Nevertheless, some firewall systems may detect false positives as a result of their oversensitivity.

There is a possibility that the system is blocking a specific Internet service provider or a CDN request.

How to Fix a 502 Bad Gateway Error?

The 502 Bad Gateway error is usually caused by server-side problems, but it may also be due to misconfigurations or temporary issues on the client’s computer.

In this section, we present various methods to fix this error:

Method 1: Refresh the Website Page

You can try the first solution by waiting a minute or two and then refreshing your current web browser. Many times, the error occurs due to an increase in traffic.

Therefore, it is usually sufficient to refresh the page. A shortcut can be obtained by pressing F5 or CTRL + F5, whereas on a Mac, pressing CMD + R will be effective.

If the website is unavailable, you can also try using an online tool such as Host Tracker or Website Planet.

In this manner, it will be possible to identify whether the error is a result of a client-side issue or a server-side issue.

Method 2: Clear Your Browser Cache

You may have outdated and corrupted files stored in your browser cache if you continue to receive the error.

It may be necessary to clear the browser cache to resolve an HTTP 502 Bad Gateway error in this case.

Cached files may contain important browser data such as bookmarks and settings, so be cautious before removing them. You can prevent this by exporting your data from the browser and importing it again later on.

Method 3: Try in Incognito Mode

Incognito mode is also a good idea for accessing the website as it will help determine whether the 502 bad gateway error message is a result of a problem with the browser.

Follow these steps to create a new Incognito window:Β 

  1. Click on the three-dot button on your browser’s screenΒ 
  2. Select New Incognito Window from the drop-down menu.

Select New Incognito Window from the drop-down menu

A browser extension may be causing the problem if the error does not appear in Incognito mode. As a result, try to gradually disable all add-ons and extensions until you can access the website once you delete the one causing the error.

You may wish to try using a different browser session if disabling extensions has not helped. For example, if you are currently using Google Chrome, try using Mozilla Firefox.

If your previous browser causes the error when the page loads normally on your new browser, your current browser likely is to blame.

If you are experiencing a problem with your browser, it is recommended that you delete and reinstall it.

Method 4: Flush DNS Servers

There are also instances when the error occurs due to DNS issues, such as incorrect IP addresses and DNS servers that are unresponsive.

You may be able to resolve this problem by flushing your DNS cache in this instance. In a similar manner to clearing your browser’s cache, this method will eliminate faulty DNS records.

One of the steps you can take is to temporarily change your DNS servers. Your Internet service provider is responsible for assigning your DNS servers by default.

If you wish to switch to a third-party DNS server, such as Google Public DNS, you can do so at any time.

Method 5: Try Another Browser

You may also be able to resolve this problem by using another browser, including Firefox, Chrome, Edge, Opera, Internet Explorer, and Safari.

Using an alternative browser that does not produce a 502 Bad Gateway error, you can now be sure that your original browser is to blame.

Assuming that you have followed the above troubleshooting advice, now may be the time to try reinstalling your browser to see if that will resolve the issue.

Method 6: Try On Another Device

Your server may be the source of an error that occurs after you have performed a particular change or update. The best way to resolve this issue is to review your website’s error logs.

In most cases, your web host offers a user interface through which you can enable website error logs. It is also possible to enable error logging for your WordPress site by adding the following lines to your wp-config.php file:

define( β€˜WP_DEBUG’, true );Β 

define( β€˜WP_DEBUG_LOG’, true );Β 

define( β€˜WP_DEBUG_DISPLAY’, false );

The wp-contents/debug.log file will contain all the generated errors, allowing you to identify which one is causing a 502 Bad Gateway error.

Method 7: Check The Error Log and Deactivate Plugins

There may be a technical issue with one or more of your plugins or themes. The reason for this is that poorly coded plugins and themes may conflict with one another.

During this event, your server will stop all scripts and queries on your website, resulting in the inaccessibility of your site.

Some websites are affected by this issue due to caching or security plugins. In some cases, these plugins block communication between servers, resulting in persistent errors.

You should disable your plugins and re-activate each one individually if you encounter an HTTP 502 error without a caching or security plugin installed.

Follow these steps to do this:

  1. Go to Plugins in your WordPress dashboard.
  2. Click on Installed Plugins.
Go to Plugins in your WordPress dashboard, then click on Installed Plugins
  1. Click Deactivate from the Bulk Actions menu.
  2. Click on the Apply button.

Click Deactivate from the Bulk Actions menu, then click on the Apply button
  1. Activate each plugin while refreshing your WordPress site.

If you encounter the 502 Error again, you have found the problematic plugin.

If you are unable to access your WordPress dashboard, you can disable them using your hosting control panel or FTP application.

Make a change to the plugins directory in the wp-content directory, by renaming it, for example, plugins-disable.

After your site has been restored to its original state following the removal of all plugins, you may rename the folder back to plugins.

If the error persists, enable the plugins one by one to identify which one is causing it. If the website still does not work, follow the same steps with your WordPress themes as well.

Method 8: Check WordPress Plugins and Themes

In many cases, the server cancels scripts and queries because of bad code on your WordPress site, possibly from a third-party plugin or theme

Furthermore, a lot of caching plugins have generated 502 errors due to misconfiguration. Several possible solutions to this problem include deactivating all plugins. You must note that deactivating a plugin will not result in a loss of data.

The steps below can be followed if you are still able to access your admin dashboard:

  1. Go to Plugins in your WordPress dashboard.
  2. Click on Installed Plugins.

Go to Plugins in your WordPress dashboard, then click on Installed Plugins
  1. Click Deactivate from the Bulk Actions menu.
  2. Click on the Apply button.
Click Deactivate from the Bulk Actions menu, then click on the Apply button

All of your plugins will be disabled as a result of this action. You will need to determine which cause of the problem is responsible if this fixes the problem.

  1. Activate each plugin while refreshing your WordPress site.

If you receive a 502 gateway error return, you have discovered the misbehaving plugin. After that, you may contact the plugin developer or submit a support ticket to the WordPress support system.

If you are unable to access your admin page, you can use FTP to access your server and rename your plugins folder to something like plugins_old, and then check your website.

If it corrects the problem, then you must test each plugin individually. Follow these steps to do this:

  1. Rename your plugin folder back to β€œplugins.”
  2. Rename each plugin folder within it one by one until you locate the problem.
Rename your plugin folder back to β€œplugins,” then rename each plugin folder within it one by one until you locate the problem

You must always keep your WordPress plugins, themes, and core up-to-date, as well as make sure you are running a PHP version that supports your site. If you need assistance, you can always contact your host.

Method 9: Restart PHP

Restarting PHP may also be an option. The host may not provide this. In this case, you may open a support ticket and request that PHP be restarted.

Method 10: Check CDNs

There may also be difficulties with your CDN or DDoS mitigation service resulting in the 502 Bad Gateway error.

An Internet content delivery network provides an additional layer of security between your server and browser, ensuring that web content is delivered efficiently.

There is, however, a possibility that this layer may encounter an issue when connecting to your origin server, which could result in a 502 error.

A notable example would be Cloudflare, where a 502 Bad Gateway error can occur in two distinct formats depending on the situation.

Based on the above screenshot, it appears that Cloudflare is responsible for the problem. If you wish to resolve this issue, you should contact their customer support department.

It is recommended that you check the Cloudflare System Status page before performing this action. Alternatively, you may choose to disable Cloudflare, however, your DNS propagation may take a few hours to complete.

As a result, if you encounter the Cloudflare error, as shown above, it means that this is a problem with your current hosting provider. If this is the case, you should contact your web host’s support team to request assistance.

Method 11: Increase PHP max_execution_time and max_input_time

The PHP timeout occurs whenever the PHP process is running longer than the maximum execution time or maximum input time specified by the PHP configuration.

In most cases, the settings for this are set in your PHP configurations on your web server. Generally, the values are set to 300 seconds by default.

In some cases, a timeout can occur during the migration process, resulting in a 502 Bad Gateway error. To resolve this issue, you may contact your web host to know what the values are set at and whether they can be increased.

Method 12: Contact Your Website Hosting

If none of these solutions resolve the error, it is recommended that you contact customer support. It is important to describe the issue and include any troubleshooting steps that you have taken to resolve it.

In addition, make sure that you provide as much information as possible and allow the support team to assist you.

Method 13: Contact Your Internet Service Provider (ISP)

When your browser, computer, and network are all functioning, and the website reports that the page or website is working, the 502 Bad Gateway error may be the result of a network issue that is the responsibility of your Internet service provider.

Method 14: Try Later Again!

If you are experiencing a 502 Bad Gateway error at this point in your troubleshooting process, there is almost certainly an issue with one of two things: Either your Internet Service Provider or the website’s network.

You may even be able to confirm that information directly with one of the two parties if you contact them.

In any case, you are not the only person experiencing this error and so you will have to wait until it is resolved for you.

502 Bad Gateway Error Variations

There is no requirement for a particular browser, operating system, or service to display the error. Nevertheless, its appearance can vary in several ways

You may encounter some alternatives for this error on the internet such as Temporary Error (502), 502 Error, Error 502, 502 bad gateway Cloudflare, 502 bad gateway Nginx, 502 bad gateway AWS, etc.

It is important to note that some websites or services have customized 502 Error pages which are likely to look different:


A 502 Bad Gateway error message is displayed by Chrome when the server encounters a temporary error and is unable to complete your request.

In addition, Chrome recommends that you try it again after 30 seconds. You may wish to try accessing the website from a different browser window if the problem persists.

The 502 error in Chrome


If GitLab’s reverse proxy server does not receive a response from GitLab’s origin server for a prolonged period, GitLab will display a 502 Bad Gateway error. Additionally, the error page provides instructions for resolving the problem.

The 502 error in GitLab


There is an error 502 that appears on Twitter when a service is temporarily overloaded. An illustration is incorporated with a clear and concise message in a playful manner. Those interested in real-time data statistics can also check out Twitter Status.

The 502 error on Twitter

How does 502 Bad Gateway Error Affects SEO?

The 502 error code is generated when there is a network error that prevents the server from completing the request.

It is important to note that if this error occurs frequently and for an extended period, it can negatively affect the search engine optimization of your website.

If a requested page is not served, visitors may leave your site, resulting in a poor user experience. Further, the longer your site remains unavailable, the greater your bounce rate will be.

The search engines will also view a page with a 502 Error as broken, which will prevent the search engine from indexing and ranking the page.

In light of this, it is essential to determine what factors are causing the error to resolve it as soon as possible for the sake of search engine optimization.

Frequently Asked Questions

In this section, we will answer some frequently asked questions to help you in solving the error:

Why Do I Get a 502 Bad Gateway Error?

The 502 Bad Gateway Error is a general error message that indicates there is something amiss with the website’s server communication. However, it will not identify the exact cause of the problem.

Does 502 bad gateway mean blocked?

You may receive a message on your computer screen that states β€œ502 bad gateway”. This occurs when the server that is acting as a proxy or gateway is not receiving an adequate response from another server.
You will not be able to determine the underlying cause of this error since it is a generic error. Therefore, it is impossible to indicate whether it is blocked or not without conducting additional research.

Is 502 Bad Gateway a Virus?

Generally, the 502 Bad Gateway Error is not the result of a virus. It occurs when the website’s server is unable to communicate with the website.


Various methods are discussed in this article to remedy the issue of a 502 Bad Gateway Error, including its causes, variations, and effects on search engine optimization.

We would like to express our sincere appreciation for reading this article. If you have any questions or comments, please feel free to use the comment section.

Please follow us on Facebook and Twitter if you are interested in staying up to date with our articles.

Leave a Reply