# org.apache.kafka.common.errors.ZooKeeperConnectionLossException: Connection loss during KRaft controller election

- **ID:** `kafka/zookeeper-connection-loss-during-kraft-election`
- **Domain:** kafka
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

During KRaft migration or mixed-mode operation, a ZooKeeper connection loss disrupts the controller election process, leaving the cluster without a leader.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Kafka 3.5.0 | active | — | — |
| Kafka 3.6.0 | active | — | — |
| Kafka 3.7.0 | active | — | — |

## Workarounds

1. **Restart the KRaft controller process with 'bin/kafka-server-stop.sh && bin/kafka-server-start.sh config/kraft/server.properties' to force a new election.** (85% success)
   ```
   Restart the KRaft controller process with 'bin/kafka-server-stop.sh && bin/kafka-server-start.sh config/kraft/server.properties' to force a new election.
   ```
2. **Ensure ZooKeeper quorum is stable and network latency between ZooKeeper and Kafka brokers is below 10ms. Use 'echo stat | nc zookeeper-host 2181' to check ZooKeeper state.** (90% success)
   ```
   Ensure ZooKeeper quorum is stable and network latency between ZooKeeper and Kafka brokers is below 10ms. Use 'echo stat | nc zookeeper-host 2181' to check ZooKeeper state.
   ```

## Dead Ends

- **Restarting only ZooKeeper servers** — Restarting ZooKeeper alone does not re-trigger the KRaft election; the controller process must be restarted. (90% fail)
- **Raising zookeeper.session.timeout.ms** — Increasing ZooKeeper session timeout delays the failure but does not prevent connection loss due to network issues. (80% fail)
