When visiting a website you can get:
502 Bad Gateway
The 502 Bad Gateway, NGINX error has two aspects to it that you must understand to fix it.
The first is the 502 error aspect. A 502 http error is saying that a gateway device is unable to send the webpage to the browser. Secondly, the NGINX aspect of the error tells us that the web server hosting the website is an NGINX web server.
Why is this useful? Because it tells us that the web server received some form of request from the browser and therefore the issue is most likely on the web server end, rather than a problem with your local computer.
With this knowledge in mind, here’s how to go about troubleshooting the error:
If the error is occurring on all websites, try resetting your router. Failing that, contact your ISP, they may be doing some internet caching that has failed.
If the error is only occurring on one website, you can try the above, but also try clearing your browser cache.
If you own the website with the error, there is probably an issue with the communication between your NGINX web server and your router / gateway / proxy server. Check that the IP settings are correct on the NGINX server and router / gateway device / proxy server, that your router / gateway and proxy server settings are correct and that your ISP isn’t caching your site incorrectly.