nginx
network_error
ai_generated
partial
upstream connection reset by peer while reading response header from upstream
ID: nginx/upstream-connection-reset-by-peer
82%Fix Rate
83%Confidence
1Evidence
2024-06-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| nginx 1.18.0 | active | — | — | — |
| nginx 1.20.2 | active | — | — | — |
| nginx 1.22.1 | active | — | — | — |
| nginx 1.24.0 | active | — | — | — |
| nginx 1.25.3 | active | — | — | — |
Root Cause
The upstream server forcibly closes the TCP connection (RST packet) before sending a complete response, often due to application crash or timeout.
generic中文
上游服务器在发送完整响应之前强制关闭TCP连接(RST包),通常由应用程序崩溃或超时引起。
Official Documentation
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_next_upstreamWorkarounds
-
85% success Check upstream application logs for crashes or timeouts; fix the application to handle requests gracefully
Check upstream application logs for crashes or timeouts; fix the application to handle requests gracefully
-
80% success Add retry logic with proxy_next_upstream: proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
Add retry logic with proxy_next_upstream: proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
-
60% success Increase upstream keepalive settings to reduce connection churn: keepalive 32;
Increase upstream keepalive settings to reduce connection churn: keepalive 32;
中文步骤
检查上游应用程序日志中的崩溃或超时;修复应用程序以优雅处理请求
使用proxy_next_upstream添加重试逻辑:proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
增加上游keepalive设置以减少连接变更:keepalive 32;
Dead Ends
Common approaches that don't work:
-
80% fail
Connection timeout only affects initial handshake, not response reading; RST occurs after connection is established.
-
70% fail
HTTP version change may affect keepalive but doesn't prevent RST from upstream.
-
65% fail
This disables keepalive but upstream may still send RST if it crashes.