502 bad gateway error: What it is and how to fix it

Camryn Smith

Jan 18, 2024 — 3 min read

A 502 error means there's been a communication breakdown between servers. Find out what causes it and how to fix it.

Internet error messages are confusing, with strange codes impossible for the average user to understand. But don’t panic; we’re to explain exactly what a 502 error is and what to do if you see one.

Every time you type in a URL, that request goes through a gateway. In the case of a 502 bad gateway error, the server acting as the gateway, or proxy, received an invalid response from the main server.

In other words, there’s been a communication breakdown. While it’s out of your hands for the most part, there are a few things you can try to resolve the issue.

A 502 Bad Gateway error isn’t as bad as it sounds

A 502 error is one of many HTTP status codes, and it’s also fairly common. While it may look serious, it generally just means there’s an error in communication between servers and it’s easy to fix. You might also see it show up as:

  • error 502
  • 502 error
  • HTTP 502
  • 502 service temporarily overloaded
  • 502 bad gateway NGINX
  • Bad gateway
502 error causes

Reasons you may be getting a 502 error

There are a handful of possibilities as to why the 502 error message appears on the website you’re trying to access.

  1. DNS changes – During server migration, domains sometimes need changes in the Domain Name System or DNS, the communication link between domain names and IP addresses. This can take hours to become fully activated.
  2. The origin server isn’t working – The server might be down, there might be a connectivity issue or there’s simply too much traffic. This could be caused by an event causing unusually high numbers of visitors or just simply coincidence. 
  3. The server has failed – This can, and does, happen due to a crash or routine maintenance.  Servers can fail for a number of reasons but usually from being overloaded with requests. 
  4. The firewall is blocking the server transmission – A firewall is in place to block transmission between servers and its main purpose is to provide protection. Sometimes, a firewall can mistake safe content for malicious content and stop the safe content in its tracks.

6 ways to troubleshoot a 502 error message

How to fix a 502 error message

Most often, a 502 bad gateway error has nothing to do with you as a visitor to the site. There are, however, a few things you can try just to be sure it’s not something on your side. Try these troubleshooting ideas in order because you might fix the issue faster than expected.

  1. Refresh the page – Just click the refresh button in your browser window or press F5 on your keyboard. If you get lucky, this will solve the problem so you can get back to the task at hand.
  2. Start a new browser session – When starting a new session, simply close all open browser windows and then open a new one.
  3. Restart your equipment – Sometimes a restart is all it takes to get things back to normal. Be sure to also reboot your networking equipment such as your modem and router.
  4. Clear your cache and cookies – If you previously visited a site with a 502 error and the files were saved, clearing your cache and cookies is a smart idea. Keep in mind that cookies keep track of where you’ve been on a site, what you like on the site, etc.
  5. Change your DNS server – You might have the default servers assigned by your ISP. Try using open DNS servers like Google’s Public DNS.
  6. Contact the website administrator or your ISP – Notifying the right people can make a difference especially if they’re unaware of the problem.

Other common error codes

Anytime you see an error message beginning with “5” that means the server isn’t able to perform the request. A “4” means it’s a client-side error, or rather, the error occurs from your side of the computer, not the server you’re trying to reach. In addition to a 502 bad gateway error, you might also see:

502 error FAQs

How do you fix a 502 bad gateway error?

While a 502 error has nothing to do with you visiting the site, you can try to refresh the page, start a new browser session, restart your equipment, clear your cache and cookies, change your DNS server or even contact the website administrator or your ISP. 

A 502 bad gateway error can be caused by a number of things like DNS changes, the origin server not working, the server failing or a firewall blocking the server transmission. 

A bad gateway error is a communication error. It means that the web server, acting as a proxy or gateway, received an invalid response from another server.

Since 502 errors are due to errors on the server side, you can’t really prevent them since they aren’t caused by you specifically. But, you can troubleshoot them when they occur. 

Camryn Smith

Written by:

Camryn Smith

Cammy is a writer with Allconnect, growing her broadband industry knowledge for over a year on the internet marketplace. Her expertise lies in home internet and broadband service with a focus on providers, plans… Read more

Robin Layton

Edited by:

Robin Layton

Editor, Broadband Content

Read bio