Kafka Error PREFERRED_LEADER_NOT_AVAILABLE
Error code 80 · Retriable Broker
The preferred leader was not available.
Common Causes
- Preferred leader (first replica in the ISR assignment) is offline or not in the ISR when `auto.leader.rebalance.enable=true` triggers a preferred leader election
- Broker hosting the preferred leader just restarted and is still catching up on log replication before it can accept leadership
- Preferred leader broker has high GC pauses or I/O latency causing it to fall out of ISR temporarily
Solutions
- This is retriable — the client will retry against the current leader; the preferred leader will take over automatically once it rejoins the ISR
- Monitor `kafka.controller:type=KafkaController,name=PreferredReplicaImbalanceCount`; if consistently high, run `kafka-leader-election.sh --election-type PREFERRED` after confirming preferred brokers are healthy
- Investigate the preferred broker for GC pauses, disk I/O saturation, or network issues causing it to drop out of ISR
Diagnostic Commands
# Show partition leader vs preferred replica
kafka-topics.sh --bootstrap-server localhost:9092 --describe | awk -F'\t' '$0 ~ /Leader/ {split($0,a,"Leader: "); split(a[2],b," "); split($0,c,"Replicas: "); split(c[2],d," "); if (b[1] != d[1]) print $0}' | head -20
# Preview which partitions need leader election
kafka-leader-election.sh --bootstrap-server localhost:9092 --election-type PREFERRED --all-topic-partitions --dry-run 2>&1 | head -20
Debugging Kafka errors? Conduktor Console gives you real-time visibility into your cluster. Explore all errors in the Error Decoder.