How do I troubleshoot a 502 error with nginx / node?

March 24, 2019 543 views
MongoDB Node.js Nginx Ubuntu 16.04

I have an ubuntu server that I use for development. It was working perfectly fine until I got an email from DO saying “We’ve had to reboot your Droplet as a result of an issue with the physical node that hosts your Droplet.” and then that they were performing an emergency droplet migration.

Since then I can’t access my site. Before it would start up when rebooting just fine, but now I get a 502 every time. MongoDB should start on startup, and node gets run with PM2. I can see the output from node and it starts just fine like it normally would, but when making a request, it returns 502 and doesn’t seem to reach node at all.

I don’t know a lot about servers, and had to pay someone to setup nginx and the certificates for me, but none of that configuration should have changed since it was working. I in fact hadn’t even made any code changes since before the droplet failure.

Any advice would be appreciated.

1 Answer

Solved, an environment variable was overriding my port number, causing it to start on the wrong port.

Have another answer? Share your knowledge.