Here are some basic ways you can try fixing a 502 Bad Gateway error.
Reload the web page. Sometimes servers are having a hard time communicating and there’s a glitch somewhere. You can easily check if it was just a fluke issue by reloading the page. Make sure you wait at least a couple minutes after you see the error—sometimes there’s just a temporary problem with the origin server.
Clear your browser cache and cookies. Sometimes your browser can collect cookies and cache from websites you visit over time. When this happens, your computer can show errors and have problems connecting to servers. Clearing your cache will help you start fresh.
Check for server issues or connectivity issues. Many websites require multiple servers or even use third-party web hosts. If a website is having this error, it could be due to a connectivity issue. The best thing you can do in this case is to wait for the server to finish solving the problem and try accessing the website again at a different time.1
Figure out if there’s a DNS issue. As we talked about earlier, a DNS (domain name system) problem happens when the domain doesn’t resolve to the correct IP address. If you think this might be the problem, you can try what’s called “flushing” your DNS cache. It’s a lot like clearing your cache and cookies but more in depth.
Temporarily disable your firewall. Remember that a firewall is what protects your computer from viruses and malware. Sometimes your firewall is overreacting to a site that’s actually safe. If you use a third-party firewall, try temporarily disabling it to see if that solves the 502 Bad Gateway error.2 If the error goes away, you’ll know your firewall just didn’t like the website you were trying to access.