111
nginx
network_error
ai_generated
true
连接到上游时连接被拒绝(111),客户端:192.168.1.1,服务器:example.com,上游:"http://127.0.0.1:8080"
connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.1.1, server: example.com, upstream: "http://127.0.0.1:8080"
ID: nginx/upstream-server-refused-connection
95%修复率
90%置信度
1证据数
2024-09-12首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| nginx 1.24.0 | active | — | — | — |
| nginx 1.22.1 | active | — | — | — |
| nginx 1.20.2 | active | — | — | — |
根因分析
上游服务器未在指定端口或 IP 上监听,可能是因为它未运行或绑定到了不同的地址。
English
The upstream server is not listening on the specified port or IP, either because it is not running or is bound to a different address.
官方文档
https://nginx.org/en/docs/http/ngx_http_upstream_module.html解决方案
-
Verify the upstream service is running: `sudo systemctl status myapp` or `netstat -tlnp | grep 8080`. Start it if needed: `sudo systemctl start myapp`.
-
Check if the upstream is listening on a different interface (e.g., 0.0.0.0 vs 127.0.0.1). Update the proxy_pass directive to match the actual listening address.
-
If using a Unix socket, ensure the socket file exists and has correct permissions. Example: `ls -la /var/run/myapp.sock` and adjust nginx upstream to `server unix:/var/run/myapp.sock;`
无效尝试
常见但无效的做法:
-
90% 失败
Connection refused is an immediate TCP error; timeout does not help.
-
70% 失败
The error is about TCP connection, not URI path issues.
-
80% 失败
Nginx is working fine; the upstream service is down or misconfigured.