Kafka Exception UnknownLeaderEpochException
org.apache.kafka.common.errors.UnknownLeaderEpochException
Retriable
Broker
The request contained a leader epoch which is larger than that on the broker that received the request. This can happen if the client observes a metadata update before it has been propagated to all brokers. Clients need not refresh metadata before retrying.
Common Causes
- Client has newer metadata than the broker — typically during a rolling upgrade where the client connected to an upgraded broker and then retries against a not-yet-upgraded broker
- Follower received a fetch or produce request with a leader epoch that it has not yet observed in its own log
- Clock skew or metadata propagation delay causing a newly elected leader's epoch to not yet be known to all brokers
Solutions
- This is retriable — the client will back off and retry; the broker will catch up on leader epoch propagation
- During rolling upgrades, ensure each broker is fully caught up (`UnderReplicatedPartitions=0`) before restarting the next one to minimize epoch propagation lag
- If persistent, check for networking issues preventing brokers from receiving controller metadata updates promptly
Example Stack Trace
org.apache.kafka.common.errors.UnknownLeaderEpochException: The leader epoch in the request is newer than the epoch on the broker.Diagnostic Commands
# Check for under-replicated partitions
kafka-topics.sh --bootstrap-server localhost:9092 --describe | grep -c 'UnderReplicated'
# Look for related errors in broker logs
grep 'UnknownLeaderEpoch\|UNKNOWN_LEADER_EPOCH' /path/to/kafka/logs/server.log | tail -20Related
Protocol error: UNKNOWN_LEADER_EPOCH (code 75)
Related Broker exceptions: CorruptRecordException · FencedLeaderEpochException · LeaderNotAvailableException · NetworkException · NotEnoughReplicasAfterAppendException · NotEnoughReplicasException · NotLeaderOrFollowerException · TimeoutException
Hitting
UnknownLeaderEpochException in production? Conduktor Console gives you real-time visibility into clients, consumer groups, and broker health. Browse every Kafka exception or protocol error code.