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!
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.
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:
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