502 Bad Gateway Error: Simple Explanation and How To Fix


502 Bad Gateway Error is a HyperText Transfer Protocol (HTTP) status code occurring when a gateway receives an inadequate response from the other servers.

502 Bad Gateway error

To make it clear, 502 Bad Gateway error is an indicator showing that there is an issue in a website’s server communication. Also, this error does not actually tell you the exact issue, it just serves an error web page to website’s visitors.

Causes of a 502 Bad Gateway error

There are a number of reasons that might lead to a 502 error. Here are the most common causes:

  • Server overload: when an unexpectedly high amount of traffic accesses the site and the server can not “server” all of them because it has exceeded the operational memory capacity
  • Request restricted by a firewall: when the request is blocked by a firewall
  • Code errors: sometimes an error in a website’s code may make the wrong requests that cannot be answered correctly, making this error to show up
  • Network errors: DNS issues, routing problems, and ISP related issues can also lead to a 502 Bad Gateway error
  • Server timeouts: when a server takes too long to complete the request
  • Browser error: occasionally, browser extension can cause website displaying error and provoke the 502 Bad Gateway error

502 Bad Gateway error

Related Stories

Dealing with 502 Bad Gateway Error

For Users

  • Reload the page: When you see this error, maybe the server is overloaded with an unexpected high amount of traffic. Or there is a normal issue on the server connectivity. If you wait one or two minutes, then refresh the page, you might see this error disappear.
  • Clear your browser cache: There is a case that a corrupted file staying in your browser might cause a 502 Bad Gateway. If you clear the cache or remove the cookies, it can help in resolving this error.
  • Switch to another browser: If you meet this error in one browser, you can try to try another one to check whether other browsers have this error or not. If the error occurs with all the browsers, you know that the problem is not here.
  • Reset your Internet configuration: You can try to restart your internet modem. Then wait for your computer to connect to the internet again, open the browser and check whether the page can be load or not.


For developers

  • Check the server connectivity

If your website server is under maintenance or down for any reason, your visitors will meet the 502 Gateway Error page.

If your server is actually down, you have to wait until it works again to solve the error.

You don’t want to contact your server provider, you can run a ping test to check whether your server is reachable or not.

  • Check for any DNS modifications

If you have recently changed your host server or your website’s IP address, your domain’s DNS records changed as well. This could evoke a 502 Bad gateway error.

You have to wait until these DNS changes are fully completed or check if the IP in the records is set correctly without any typo.

502 Bad Gateway error

DNS is the phonebook of the internet. When people access websites through domain names such as mageplaza.com, ,web browsers interact through Internet Protocol (IP) addresses.

  • Clear local DNS cache

If the DNS has changed and the cache has not been cleared, the 502 error can occur.

To do this, you open your cmd prompt for windows users, then open the command prompt on your windows PC and type inconfig / flushdns then press enter.

  • Check your logs

The server logs provide particular details about errors being thrown on the server. You should sift through them to uncover and respond to any error alarm. Then resolve faulty firewall configuration

As your firewall protects your website from any malicious traffic, it sometimes can deem a request from a content delivery network. Because it is a faulty firewall configuration. When your firewall rejects the content delivery network, your visitors will be shown the 502 error page.

So, you should temporarily disable your firewall and see whether the issue still occurs or is resolved. If the error still persists, then check your configuration.

  • Find bugs on your website’s programming

There is a chance that your website’s code can have bugs making your server wrongly answer requests form a content delivery network.

Check your codes to detect bugs or take a development machine to do the checking. This will help you to solve the problem or see the exact moment where the issue was raised.

  • Disable CDN temporarily

Another reason could be that the server is targeted by a DDOS attack.

502 Bad Gateway error

A DDOS (distributed denial-of-a-service) attack is a malicious action to disrupt normal traffic of a server, service or network by a flood of online traffic

To avoid this problem, you should use content delivery network providers to mitigate these DDOS attacks on the server.

  • Contact your hosting provider

If you cannot figure out the solution to your 502 Bad Gateway error, you might need to contact your hosting provider for assistance.

If the root of the error is on the hosting provider’s side, they will fix it eventually. However, in case the problem originated from your website, they will possibly help you to find the solution.


A 502 Bad Gateway error is not something to be panic about. It’s just an error evoked from a communication problem between servers. Magesolution and ArrowHiTech hope that you can fix your error by trying these solutions. If you have any new solution, quickly tell us in the comment box below or email us for more supports:

2435 Total Views 5 Views Today