Report this

What is the reason for this report?

502 Bad Gateway : connect() failed (111: Unknown error) while connecting to upstream

Posted on September 23, 2021

Hi I have a MERN stack app and it always worked like charm until this morning when we suddenly got a 502 Bad Gateway(without touching anything). I’ve seen another Post on here which is resolved but any of the steps in that post didn’t help me anything at all.

Not sure, how can I find out? Operating system: Ubuntu 18.04

Expected behavior: To work again like before

Actual behavior: A 502 Bad Gateway

Error log from /var/log/nginx/error.log looks like this

2021/09/23 16:34:25 [error] 23460#23460: *11 connect() failed (111: Unknown error) while connecting to upstream, client: x.x.x.x, server: 
, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:5000/favicon.ico", host: "x.x.x.x"

Would appreciate your help, Thanks



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!

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.

Hello,

The error indicates that your Node service is not running so the Nginx service is unable to connect.

What you need to do is to start your Node service. This would depend on your personal setup, but for example if you are using pm2, you could get a list of the available services with pm2 list and then you can start your application with pm2 start your_app_name.

If you do not use pm2, what I could suggest is running the history command so that you could see what were the previous commands executed on the server which could point you in the right direction on how the Node services was first setup and started.

Let me know how it goes! Regards, Bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.