# error: read tcp 192.168.1.10:8080->192.168.1.20:5432: read: connection reset by peer

- **ID:** `go/http-connection-reset-by-peer`
- **Domain:** go
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

对端服务器主动关闭了TCP连接，可能因超时、崩溃或防火墙干预。

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.19 | active | — | — |

## Workarounds

1. **** (75% success)
   ```
   实现连接池和重连逻辑：
for {
    resp, err := client.Get(url)
    if err != nil {
        // 重新创建连接
        client.CloseIdleConnections()
        continue
    }
    break
}
   ```
2. **** (80% success)
   ```
   设置合理的超时和重试：
client := &http.Client{Timeout: 10 * time.Second}
for i := 0; i < 3; i++ {
    resp, err := client.Get(url)
    if err == nil { break }
    time.Sleep(2 * time.Second)
}
   ```

## Dead Ends

- **** — 连接已无效，后续读写会失败。 (100% fail)
- **** — keepalive不能防止对端重置，只能检测死连接。 (70% fail)
