Talking about 502 Bad Gateway Error it actually refers to the issue where the web server you are connected to acts as a proxy to fetch information from a different server and the process results in a weird response from that particular server. The name given to these error differs with different websites like
Temporary Error (502)
HTTP Error 502 Bad Gateway
502 Service Temporarily Overloaded
HTTP 502
502 Bad Gateway Nginx

Here are some fixes that you can try to fix this error
The first thing you can do no matter what the reason is for not accessing a particular site, you just can check if your friend or anyone else is also facing the same problem of not connecting to the same site.
Try refreshing the page
It is better to refresh the page to solve 502 error. Just press F5 button to refresh button to refresh the page.
In case the site is down for all, there is nothing can be done that about it.
Try another Browser
It is recommended that you refresh the page as it can resolve the error. There is possibility that the browser you are using may be resulting in 502 Bad Gateway error. The best way to cross check this is to try opening the same site in a different browser.
In case you encounter the same error in a different browser too then it will be clear that it is not an issue with the browser and you can move to the next fix.
Clear Cache & Cookies from your Browser
In case the site works in a different browser then the chances are that the primary browser has dated cached corrupt/outdated files that directly results in 502 error. You can try to remove those cached files and then try to access the site to check if the issue is resolved.
Inspect Plugins & extensions
In case you have extensions existing on the browser, then there are chances that either of the extension or more may be the cause of the issue.
In such cases try to disable all the extensions and then try to connect to the site. In case the error still re-occurs then there are possibilities of a plugin resulting in error. Now, try to enable the plugins individually to identify which one is causing the error.
Restart the Devices
The problems can be with your PC or networking device like Wi-Fi/router/modem etc. You can just restart your PC and networking devices which may fix the problem.
Change DNS Servers
At times issues with DNS problems can lead to 502 errors. You can try changing DNS server to see if the problem is solved. This is bit difficult especially when you haven’t changed it in t past on your own. In case you haven’t done in the past ensure that you consult someone who already knows about it so that DNS server can be changed properly.