# UNAVAILABLE: grpc: connection error: connection reset by peer

- **ID:** `grpc/grpc-connection-reset-by-peer`
- **Domain:** grpc
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 76%

## Root Cause

The TCP connection was reset by the remote peer due to a crash, timeout, or firewall interference.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| gRPC v1.42.0 | active | — | — |
| gRPC v1.55.0 | active | — | — |
| gRPC v1.61.0 | active | — | — |

## Workarounds

1. **Configure the server to handle graceful shutdown and increase idle timeout. Example in Go: server := grpc.NewServer(grpc.KeepaliveParams(keepalive.ServerParameters{MaxConnectionIdle: 5 * time.Minute}))** (75% success)
   ```
   Configure the server to handle graceful shutdown and increase idle timeout. Example in Go: server := grpc.NewServer(grpc.KeepaliveParams(keepalive.ServerParameters{MaxConnectionIdle: 5 * time.Minute}))
   ```
2. **Use a connection pool with retry logic. In Python, use grpc.aio with automatic reconnection: channel = grpc.aio.insecure_channel('localhost:50051'); await channel.channel_ready()** (80% success)
   ```
   Use a connection pool with retry logic. In Python, use grpc.aio with automatic reconnection: channel = grpc.aio.insecure_channel('localhost:50051'); await channel.channel_ready()
   ```
3. **Check firewall or load balancer settings for idle connection timeouts. Increase TCP keepalive settings on both client and server (e.g., net.ipv4.tcp_keepalive_time=600).** (70% success)
   ```
   Check firewall or load balancer settings for idle connection timeouts. Increase TCP keepalive settings on both client and server (e.g., net.ipv4.tcp_keepalive_time=600).
   ```

## Dead Ends

- **** — Connection reset is not a timeout issue; longer timeouts won't prevent the peer from resetting the connection. (80% fail)
- **** — TLS is not the cause; disabling it reduces security without fixing the reset. (70% fail)
- **** — The server or network issue persists; client restart doesn't address the root cause. (85% fail)
