By stelian
Hi all,
Today the node server was throwing a 502 Bad Gateway error, after checking the error file we have the following message:
2023/10/04 11:43:12 [error] 48367#48367: *24 connect() failed (111: Connection refused) while connecting to upstream, client: 188.27.129.65 request: “GET /api HTTP/2.0”, upstream: “http://127.0.0.1:8080/api”
We already checked the
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!
Accepted Answer
Hi there,
The error message connect() failed (111: Connection refused) while connecting to upstream
means that Nginx tried to pass a request to the upstream server but was unable to establish a connection.
This is most likely caused by one of those two things:
Node Server Not Running: Ensure that the node server is running. Check the process:
ps aux | grep node
If it’s not running, you will have to start your app again. If it is running, check its logs for any errors and feel free to share them here.
Port Misconfiguration:
Ensure that the node server is running on port 8080
, as Nginx is trying to forward requests to that port.
Here is also a quick video demo on how to troubleshoot this:
Best,
Bobby
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.