nginx
proxy_error
ai_generated
true
connect() failed (111: Connection refused) while connecting to upstream
ID: nginx/upstream-connection-refused
88%Fix Rate
90%Confidence
3Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1 | active | — | — | — |
Root Cause
nginx cannot reach the backend. Backend not running, wrong port, or listening on different interface.
genericWorkarounds
-
95% success Verify the backend is running and listening on the expected port
curl -v http://127.0.0.1:8000 # test backend directly; ss -tlnp | grep 8000
Sources: https://nginx.org/en/docs/
-
90% success Check backend is listening on correct interface (0.0.0.0 vs 127.0.0.1)
If backend listens on 127.0.0.1 but nginx uses proxy_pass to container IP, connection refused
-
82% success Check firewall rules and SELinux if enabled
sudo setsebool -P httpd_can_network_connect 1 # SELinux blocks nginx upstream by default
Dead Ends
Common approaches that don't work:
-
Change proxy_pass to use hostname instead of IP
55% fail
DNS resolution adds latency and can fail; use IP for local backends
-
Restart nginx assuming the issue is with nginx
80% fail
nginx is working correctly by reporting the error; the backend is the problem