The 502 Bad Gateway error normally originates on the server-side and has nothing to do with your own PC. The other server’s response was insufficient, according to this error. This error can be seen on any device, browser, or operating system.
Every website can customize this error page, so instead of seeing the default error page above, you’ll get a custom error page. 504 Gateway Timeout Error and Error 500 Internal Server Error are two more typical server-side issues.
How do I fix a 502 Bad Gateway?
Users attempting to connect to an Internet website or service will encounter all of these challenges. Even if this is the case, there may be methods for resolving the problem in the local system.
The most likely cause, especially if you’re trying to connect to a popular service like Google, Twitter, or Facebook, is that it’s a temporary problem. The 502 error page that Google presents to users states as much.
Reloading the page should be your first option.
If you can’t gain access to a service right away due to a 502 Bad Gateway error, all you have to do is wait around half a minute before attempting to connect to the site or server again.
To reload the page, press CTrl-F5, which will bypass the cache and ask the browser to download all files from the webserver in question. This instantly resolves all the cache-related issues on the local system.
If the problem is just temporary, then reloading the server or website may go a long way in helping to resolve the issue.
Start a Private Window as a second option.
Starting a new Private or Incognito session in your browser is another approach to remedy this error. Simply shut all of your current tabs and open a new Private or Incognito window. If you encountered this error as a result of a browser issue, restarting your browser in Private mode should repair the problem.

Option 3: Delete Cookies from Your Browser
There’s a possibility that your browser’s corrupted files are creating the 502 Bad Gateway issue. If you delete your browser’s cache, you might be able to fix the problem. You should also delete the cookies from your browser. It may also be useful in resolving this issue.

Option 4: Switch to a different browser
You could try using a different browser like Chrome, Safari, Firefox, or Internet Explorer. If the error disappears when you switch browsers, it means the issue was caused by the browser. You can even try reinstalling the browser to see if it fixes the issue.
Option 5: Double-check your DNS settings
Checking your domain’s DNS records is another remedy for this problem. Problems with DNS records can occasionally trigger the Bad Gateway error. If you haven’t altered the DNS records, double-check that the IP address in the records is valid and that there are no typos.
Option 6: Take a look at the Themes and Plugins (WordPress)
A problem with a theme or plugin might also cause 502 bad gateway errors, therefore you should double-check them. If you still have access to the WordPress dashboard, go to plugins and select ‘Deactivate’ from the ‘Bulk Actions’ section. Enable the plugins one at a time, and make a point of refreshing the page after each one.

Option 7: Check Your Content Delivery Networks (CDNs)
CDN (content delivery network) or DDoS (distributed denial of service) mitigation services may be causing the 502 bad gateway error. This implies that there is a problem on CloudFlare’s end, and you should contact their customer service team to rectify it. You can also disable Cloud Flare as an alternative, but bear in mind that DNS propagation may take a few hours.

Why do I keep getting bad Gateway 502?
Bad Gateway failures are frequently triggered by problems with web servers over which you have no control. However, there are situations when there is no true problem but your browser thinks there is because of a problem with your browser, a problem with your home networking equipment, or another reason beyond your control.
One or more of the following factors could be causing your bad gateway 502 errors:
- Domain name not resolvable: This problem can occur if the domain name is not pointing to the correct IP address or if it does not point to any IP address at all. Changes in DNS settings may also take some time to propagate due to DNS propagation. Reflection can take anywhere from 24 to 48 hours, depending on the TTL defined for each record on the DNS.
- Server unavailable: The origin server is unavailable. This could be because the server is unavailable for some reason or because there is no connectivity with the server.
- The connectivity between the edge servers and the origin server is disrupted by a firewall: This could be due to your CMS’s security plugins. Servers can be prohibited from reaching the originating server as part of the DDOS protection and mitigation procedure or owing to some severe firewall regulations.
Is the 502 Bad Gateway error code permanent?
While the 502 Bad Gateway error normally indicates a networking issue beyond your control, it could also be a very short-term issue. Reloading the website again is frequently successful. Close all existing browser windows and then open a new one to start a new browser session. Then try again to open the web page.
Conclusion
Whether you like it or not, you’re bound to run into a 502 bad gateway error at some point. Now that you know what 502 errors are and why they happen on your website, you should be able to keep an eye on these warning signs and take steps to correct them.