# LEADER_NOT_AVAILABLE: No leader for partition N in topic X

- **ID:** `communication/kafka-leader-not-available`
- **Domain:** communication
- **Category:** runtime_error
- **Error Code:** `LEADER_NOT_AVAILABLE`
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

The Kafka broker that was the leader for a partition has crashed or is unreachable, and the controller has not yet elected a new leader via ISR (In-Sync Replicas).

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Kafka 3.4 | active | — | — |
| Kafka 3.5 | active | — | — |
| Kafka 3.6 | active | — | — |

## Workarounds

1. **Run `kafka-leader-election.sh --bootstrap-server localhost:9092 --election-type preferred --topic X --partition N` to trigger a clean leader election from ISR.** (85% success)
   ```
   Run `kafka-leader-election.sh --bootstrap-server localhost:9092 --election-type preferred --topic X --partition N` to trigger a clean leader election from ISR.
   ```
2. **Increase `unclean.leader.election.enable=true` in broker config to allow out-of-sync replicas to become leader as a last resort, then revert.** (70% success)
   ```
   Increase `unclean.leader.election.enable=true` in broker config to allow out-of-sync replicas to become leader as a last resort, then revert.
   ```

## Dead Ends

- **** — Restarting the failed broker may cause split-brain if not cleanly shut down; leader election still fails. (50% fail)
- **** — Increasing replication factor doesn't fix immediate leader unavailability; requires reconfiguration. (70% fail)
- **** — Manually setting preferred leader via kafka-leader-election.sh can cause data inconsistency if ISR is out of sync. (40% fail)
