A 502 bad gateway error occurs when you try to visit a web page, but a web server receives an invalid response from another web server.