By bikowalczyk
Hello,
I’m running nodejs app on a droplet and everything works fine, but when I try to make a GET request to my server I end up with a 502 error. The get is pointed to www.example.com/down. Everything worked fine, when I run the server locally with npm start.
This is the error log of nginx:
2018/04/01 20:17:02 [error] 22119#22119: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 95.49.110.41, server: saveinsta.me, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5000/", host: "saveinsta.me"
And my nginx config:
server_name saveinsta.me www.saveinsta.me;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
I tried the advice on another thread to change “localhost” to "127.0.0.1 ", but nothing has changed. It is possible that something is wrong with my node app code, so I’ll link it here: (https://github.com/bikowalczyk/saveinsta.me/blob/gif_server/index.js).
Any help would be greatly appreciated.
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!
You may want to update your node.js app to specify the IP address to listen on. This may resolve the issue but will also ensure that your node.js app is not listening publicly and only to the local requests from nginx.
app.listen(5000,'127.0.0.1',function(){
This comment has been deleted
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.