# org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /brokers/ids

- **ID:** `kafka/zk-timeout-on-startup`
- **Domain:** kafka
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 78%

## Root Cause

Kafka broker fails to register with ZooKeeper due to network timeout or ZooKeeper cluster unavailability during startup.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Kafka 3.4.0 | active | — | — |
| ZooKeeper 3.8.1 | active | — | — |
| Kafka 3.5.1 | active | — | — |

## Workarounds

1. **Check ZooKeeper connectivity: `echo stat | nc zookeeper1 2181` and ensure ZooKeeper ensemble is healthy (quorum formed). Then verify Kafka broker can resolve ZooKeeper hostnames via DNS.** (85% success)
   ```
   Check ZooKeeper connectivity: `echo stat | nc zookeeper1 2181` and ensure ZooKeeper ensemble is healthy (quorum formed). Then verify Kafka broker can resolve ZooKeeper hostnames via DNS.
   ```
2. **Increase `zookeeper.connection.timeout.ms` in broker config to 30000 (30 seconds) and reduce `zookeeper.session.timeout.ms` to 18000 to allow more time for initial handshake.** (75% success)
   ```
   Increase `zookeeper.connection.timeout.ms` in broker config to 30000 (30 seconds) and reduce `zookeeper.session.timeout.ms` to 18000 to allow more time for initial handshake.
   ```
3. **Example fix: set `zookeeper.connect=zk1:2181,zk2:2181,zk3:2181/kafka` and ensure `zookeeper.connection.timeout.ms=30000` in server.properties.** (90% success)
   ```
   Example fix: set `zookeeper.connect=zk1:2181,zk2:2181,zk3:2181/kafka` and ensure `zookeeper.connection.timeout.ms=30000` in server.properties.
   ```

## Dead Ends

- **** — It masks the symptom but does not fix the root cause of intermittent connectivity. (65% fail)
- **** — The broker will still fail to connect if ZooKeeper is down or misconfigured. (80% fail)
