502 Bad Gateway Error (Causes and Quick Solutions)

4 min


You just tried to access your beloved website but what you see is, an error with a message-’502 Bad Gateway’. Now you might be wondering what is happening to your site. Why you’re not able to open it into your browsers!

Don’t panic, 502 Bad Gateway error is a very common. It affects a large portion of the internet. You will be surprised to know even big names like Google, Facebook, Twitter, etc. are no exception to it.

The aim of writing this article is to make you familiar with the actual causes responsible for this error. I will talk about few quick solutions as well for both users and website owners.

Let’s understand what 502 error is?!

Each time you access a website, your browser sends out requests to different web servers. The servers are responsible to manage these requests and send back an HTTP status code with requested resources. Generally, HTTP status code does not display until any problem arrives along the way.

This is the method servers use to inform each other and end-users about any error.

502 bad gateway error may run into from time to time. Although it is not as persistent as ‘503 Service Unavailable Error’ or ‘500 Internal Server Error’ yet it is a big headache.

Generally, this error means that one of the servers over the internet is receiving an inaccurate response from another server.

How You May See 502 Bad Gateway Error

Different servers describe and display this error differently. On the basis of your server, you may see a different 502 error. However, the most common ways you may see this error are:

  • 502 Service Temporarily Overloaded
  • Temporary Error (502)
  • HTTP 502
  • 502 Bad Gateway
  • HTTP Error 502 – Bad Gateway

Possible Reasons for 502 Bad Gateway

HTTP status codes which begin with no. ‘5’ are associated with errors that happen when there is a communication issue between servers. Most of the time, issue lies within the server side.

As I said above, the error 502 appears when the origin server sends an invalid response to another server, which is acting as a proxy or gateway. Since all the requests on the internet are forwarded via gateways, it can be very difficult to find out the exact point causing this error.

However, I have tried to identify some major culprits that cause this error.

Origin Server is Not Accessible

You may see this error if your origin server is not accessible. There can be various reasons for the same such as poor or no connectivity between servers, server is temporarily down, etc.

Firewall is Blocking Request

Firewall offers protection, but sometimes it may become too over-reactive and start blocking the communication between the origin server and edge server.

The other security solutions such as security plugins, mitigation systems or DDOS protection may be responsible for blocking requests from CDS (content delivery servers), resulting in 502 gateway errors.

DNS Issue

If you recently replaced your hosting, remember DNS changes can take few hours to get fully active and propagated. How much time it would take depends on the time to live (TTL). During this time period, your site may show this error.


Quick Solutions to Resolve 502 Error

For Website Owners

If you are a website owner, there could be various reasons you are seeing 502 Bad Gateway error on your origin server. Below are few methods which may help you resolve this error.

Check Your Plugins

If you are running a WordPress site, it is necessary to inspect your plugins. Most of the time, it is seen that caching plugins lead to bad gateway error. The simplest method to check it would be disabling all your caching plugins for a short time.

For detailed solutions, WordPress users may refer 000webhost.com blog on how to easily fix 502 Bad Gateway error in WordPress.

Check for Error Logs

If you are seeing this error after a certain update on your site, there is a possibility that issue lies on your site itself. You may check your error log for any hints. If you are running a WP site, add the following code line in your wp-config.php file

define( ‘WP_DEBUG’, true );

define( ‘WP_DEBUG_LOG’, true );

define( ‘WP_DEBUG_DISPLAY’, false );

You can see all the generated entries in the debug.log file.

Check Your CDN

If you are using a Content Delivery Network or DDoS mitigation services, they may also cause bad gateway error.

If you’re using a CloudFlare, it will return a 502 Bad Gateway error once it has reached a fixed limit. In order to fix it, you may look for their customer support team support or choose to disable CloudFlare.

Check Firewall Logs

Check your firewall logs, if you are noticing unusual drops.

For Visitors

If you are a user, then this section is for you. As a user, there are various things that you can try to resolve this error. Though resolving the primary issue will always be the responsibility of the website owner yet you may try the following methods.

Refresh the Page

It is a fairly simple solution. Wait for a minute or two, then refresh the page you are on. In most of the cases, the error is temporary and a simple page refresh can do the trick.

Clear Your Browser Cache and Cookies

You may see this error if your browser contains files that were saved once you visited the site with 502 error. If it is the case, clearing browser cache and cookies can be a good approach to troubleshoot 502 bad gateway error.

Try Loading that Site on Different Browser

Try to load that site on different browsers. Incognito mode can be a good idea.

Restart Your Computer

Restart your computer and all networking equipment attached to it.

Change Your DNS Server

If you never changed your DNS server, there is a chance you still have the default servers allotted by your Internet Service Provider. You may try using open DNS server like Google Public DNS.

Was there anything we missed? If you have any another tip to fix this error, let us know in the below comment section.

Like it? Share with your friends!

Gediminas Bučiūnas

Hi, I am Gediminas Bučiūnas, a young, professional and passionate content writer at the 000webhost team. I am an avid member of various WordPress communities where I learn more about the world’s greatest CMS, WordPress from experts and share knowledge to newbies. I believe helping others is the best source of learning. Therefore, I always try to write useful and informative articles and blogs for learners. Apart from writing, I love photography and traveling.


Your email address will not be published. Required fields are marked *