# org.apache.kafka.common.errors.NetworkException: The server disconnected before a response was received. Timeout: 30000 ms

- **ID:** `kafka/network-exception-read-timeout`
- **Domain:** kafka
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 82%

## Root Cause

Kafka broker closed the TCP connection before sending a response, often due to request timeout or network congestion between client and broker.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| kafka_2.13-3.3.1 | active | — | — |
| kafka_2.13-3.4.0 | active | — | — |
| kafka_2.13-3.5.0 | active | — | — |

## Workarounds

1. **Increase `broker.request.timeout.ms` in `server.properties` (e.g., from 30000 to 60000) and restart the broker to allow longer processing time for slow requests.** (80% success)
   ```
   Increase `broker.request.timeout.ms` in `server.properties` (e.g., from 30000 to 60000) and restart the broker to allow longer processing time for slow requests.
   ```
2. **Enable TCP keepalive on both client and broker: set `socket.connection.setup.timeout.ms=10000` and `socket.connection.setup.timeout.max.ms=30000` in `server.properties`, and on the client set `connections.max.idle.ms=300000`.** (85% success)
   ```
   Enable TCP keepalive on both client and broker: set `socket.connection.setup.timeout.ms=10000` and `socket.connection.setup.timeout.max.ms=30000` in `server.properties`, and on the client set `connections.max.idle.ms=300000`.
   ```
3. **If using a load balancer, check idle timeout settings (e.g., AWS NLB idle timeout) and increase them to match Kafka's `connections.max.idle.ms`.** (90% success)
   ```
   If using a load balancer, check idle timeout settings (e.g., AWS NLB idle timeout) and increase them to match Kafka's `connections.max.idle.ms`.
   ```

## Dead Ends

- **** — The timeout is on the broker side; increasing client timeout does not prevent the broker from disconnecting. (85% fail)
- **** — Network issues (e.g., firewall, TCP keepalive) persist after reboot; the error recurs on the next request. (90% fail)
- **** — Disabling socket timeout can cause resource exhaustion and does not address the root cause of disconnection. (70% fail)
