Hi DO Team,
My droplets is working good before i power off for a long time ( 2 week ), and today i’m trying to power on my droplet, it show 502 Bad Gateway in the browser. And in the terminal when i’m trying to run pm2 restart server.js, it show … Use --update-env to update environments variables… I dont know how to fix it and make my server run again ( try to run pm2 start server.js --update-env but it not work…). Note: i’m using Nodejs + MongoDb + Nextjs and server is Ubuntu 18.04. Thank you.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
In my case when I checked the pm2 list, it seemed processes were running. So I just reloaded them using command.
Everything were okay, but in fact staging and production app still threw 502 bad gateway.
So I stopped processes and restarted them, and then everything were really worked.
I think after restarting the droplet, need to drop or stop the process and then restart that.
Hope it helps you!
Hello,
The problem that you are seeing is not really related to a droplet problem, it is definitely due to your application not running at the moment.
I would recommend starting with the following:
tail -100 /var/log/nginx/error.log
Feel free to share the error here so I could advise you further.
Regards, Bobby
tail -100 /var/log/nginx/error.log shows me the following for our application after restarting mongodb :
2020/01/16 16:26:44 [error] 25305#25305: *69279 upstream prematurely closed connection while reading response header from upstream, client: 128.227.182.203, server: lims.rgportal.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:3001/", host: "lims.rgportal.com"
2020/01/16 16:28:44 [error] 25305#25305: *69279 upstream prematurely closed connection while reading response header from upstream, client: 128.227.182.203, server: lims.rgportal.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:3001/favicon.ico", host: "lims.rgportal.com", referrer: "https://lims.rgportal.com/"
2020/01/16 16:29:53 [error] 25305#25305: *69298 upstream prematurely closed connection while reading response header from upstream, client: 128.227.1.38, server: lims.rgportal.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:3001/", host: "lims.rgportal.com"
2020/01/16 16:30:01 [error] 25305#25305: *69307 upstream prematurely closed connection while reading response header from upstream, client: 128.227.1.36, server: lims.rgportal.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:3001/", host: "lims.rgportal.com", referrer: "https://lims.rgportal.com/"
2020/01/16 16:30:01 [error] 25305#25305: *69298 upstream prematurely closed connection while reading response header from upstream, client: 128.227.1.38, server: lims.rgportal.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:3001/favicon.ico", host: "lims.rgportal.com", referrer: "https://lims.rgportal.com/"
2020/01/16 16:30:01 [error] 25305#25305: *69307 connect() failed (111: Connection refused) while connecting to upstream, client: 128.227.1.36, server: lims.rgportal.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:3001/favicon.ico", host: "lims.rgportal.com", referrer: "https://lims.rgportal.com/"
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.