What does Nginx connect() failed (111: Connection refused) mean?
Nginx reached the host but the upstream TCP connection was rejected, usually because no process listens at the configured address and port.
Nginx / Envoy · HTTP 502
Fix Nginx 502 when connect() to an upstream is refused. Verify the process, socket or port, container network, and upstream configuration.
Origin / Network Firewall
Paste a captured HTTP response or enter a status and headers. Only the status and response headers are sent; common credential headers are filtered first.
Diagnostic report
Error code / name
Fault domain
Origin / Network FirewallNginx could not open a TCP connection to its configured upstream. The exact error `connect() failed (111: Connection refused) while connecting to upstream` usually means no process is listening at that address and port, or a local policy rejected the connection.
Nginx could not open a TCP connection to its configured upstream. The exact error `connect() failed (111: Connection refused) while connecting to upstream` usually means no process is listening at that address and port, or a local policy rejected the connection.
Client -> Nginx -> TCP connect to 127.0.0.1:3000 -> RST / refused -> X 502curl -sS -v -I --connect-timeout 3 --max-time 10 http://127.0.0.1:3000/healthupstream app {
server 127.0.0.1:3000;
}
server {
location / {
proxy_pass http://app;
}
}SteadyNode's Upstream Translator recognizes Nginx gateway signatures and explains the likely connection boundary, while scheduled checks detect the public impact.
No credit card required.
Start for freeNginx reached the host but the upstream TCP connection was rejected, usually because no process listens at the configured address and port.
Only when Nginx and the application share the same network namespace. In separate containers, use the application's service name and container port.