So I was managing a Linksys EA4500 Router that was reporting "bad gateway" error 502 when attempting to access its console via a browser.
Multiple resets didn't resolve the problem. A firmware upgrade, however, did.
1. Check the back of the router for it's Hardware Version. It's next to the serial number and model number. If there is no version information, you're on Hardware Version 1.
2. Download the latest firmware image for the router. Do note the hardware version.
3. Unplug the WAN (Internet) port on the router.
4. Connect to the router with a physical cable on one of its standard Ethernet ports (not the WAN/Internet port).
5. Open a browser and browse to: http://myrouter.local
6. If that doesn't work, browse to the router's IP address.
7. The "bad gateway" should now be resolved. You're at Console Login. Login to the router.
8. Go to the Connectivity section and manually update the firmware with the file you downloaded.
9. After firmware application and reboot, you should be able to plug the WAN port back in and browse to console normally.
That should solve the issue.