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

Posted March 24, 2019 1.5k views
NginxMongoDBNode.jsUbuntu 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.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

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