Home › Data Engineering › Kafka Leader Not Available After Broker Restart
Intermediate 5 min · September 23, 2026

Kafka Leader Not Available After Broker Restart

Leader -1 after a broker restart is usually election in flight.

N
Naren Founder & Principal Engineer

20+ years shipping production backend systems. Everything here is grounded in real deployments.

Follow
✓ Production
production tested
September 27, 2026
last updated
2,085
articles · all by Naren
Before you start⏱ 20 min
  • ✓A Kafka cluster you can describe topics on
  • ✓Broker restart and replication basics
  • ✓Access to broker and client logs
 ● Production Incident 🔎 Debug Guide
⚡Quick Answer
  • Leader -1 after a restart usually means an election is in flight — verify ISR trends before restarting anything else
  • Only an in-sync replica can take over without data loss; unclean election restores writes by discarding history
  • acks=all with min.insync.replicas=2 on RF=3 stalls writes (safely) when replicas drop — that's protection working
  • Recover with preferred-replica-election, then force clients to refresh metadata before declaring victory
✦ Definition~90s read
What is Kafka Leader Not Available After Broker Restart?

Each Kafka partition has one leader replica that handles all reads and writes, while followers replicate its log. The controller tracks leadership, and clients discover it through metadata responses. LeaderNotAvailableException means the client's metadata showed no leader for that partition — typically Leader: -1 in topic describe output.

★
Think of each partition as a classroom needing exactly one teacher (leader).

The partition's data usually still exists on disk; there's just no replica currently authorized to serve it.

Leader elections happen whenever leadership changes: broker restarts, failures, or preferred-replica-election runs. The controller picks the new leader from the in-sync replica set (ISR) — replicas fully caught up with the old leader. This constraint is the heart of Kafka's durability story: only a replica holding all committed records may lead, so committed data survives leadership changes.

Elections among healthy ISR members complete in seconds.

The ISR is also the tripwire for everything else in this guide. min.insync.replicas defines how small the ISR may shrink before acks=all writes refuse; unclean.leader.election.enable decides what happens when the ISR is empty (stay dark vs elect a lossy outsider); preferred-replica-election repairs the leadership skew outages leave behind. Read the ISR list on every leader incident and the rest of the diagnosis nearly writes itself.

Plain-English First

Think of each partition as a classroom needing exactly one teacher (leader). When the teacher steps out (broker restart), the office picks a qualified substitute from trained aides (in-sync replicas) — class pauses briefly. But with no trained aide available, the office must leave class unsupervised or hand it to an untrained volunteer (unclean election) who loses what yesterday covered.

You restart one broker for a routine patch, and within seconds the alerts start: LeaderNotAvailableException across three topics, producers throwing, consumers stalling. Your first instinct is that the restart broke something. In most cases it didn't — you're watching leader election do its job, and the scariest minute of Kafka operations is also the most normal.

Still, 'normal' covers a wide range. A healthy election finishes in under two minutes and nobody pages. A stuck one — no surviving ISR replica, a durability config that can't be satisfied, clients caching the leaderless state — sits at leader -1 for twenty minutes while you restart brokers that were fine, making everything worse.

This guide teaches you to tell those two apart fast. You'll learn what the leader field and ISR list actually say during an outage, when unclean leader election is (rarely) justified, how min.insync.replicas and acks interact under failure, and the exact recovery sequence — preferred-replica-election included — that restores balanced leadership instead of a fragile pile-up on survivors.

What LeaderNotAvailableException Actually Means

Every partition has exactly one leader — the replica that accepts produces and serves reads — plus followers that replicate. Clients learn the leader from metadata responses, and LeaderNotAvailableException is the client's way of saying the metadata listed no leader for that partition. It's a routing failure, not a data verdict: the records may be perfectly safe on disk with nobody currently authorized to serve them.

Two very different situations produce the same exception, and confusing them causes most of the damage in these incidents. In situation one, an election is in flight: the old leader is gone, a new one is being chosen from the in-sync replica set (ISR), and the leader field will repopulate in seconds. In situation two, no ISR member is alive, so no legitimate election can complete and the field sits at -1 indefinitely. The first needs patience; the second needs a replica restored.

Your first command decides which world you're in: topic describe shows Leader and Isr per partition. Leader -1 with live ISR members means wait and re-check. Leader -1 with all replicas offline means waiting is futile. Teams that skip this read and restart brokers instead reliably convert situation one into situation two, because each bounce kills the replicas that were about to win the election.

📊 Production Insight
A team restarted two extra brokers during a 90-second election and stretched it to 23 minutes. Rule: describe the topic and read Leader plus Isr before touching any broker.
🎯 Key Takeaway
Leader -1 means no authorized server right now — read the ISR list to separate a transient election from a truly stuck partition.

Broker Restarts and the Leader Election Timeline

A broker restart fires a precise sequence: the controller notices the missing heartbeat, marks its led partitions leaderless, and starts elections among ISR members. Followers that were in sync campaign, the controller picks winners, and the new leaders fetch metadata updates to clients. On a healthy cluster with replication factor 3, this completes in 30-120 seconds — the window where LeaderNotAvailable is expected and harmless.

The timeline stretches when each stage degrades. Slow log recovery on restart (replaying unflushed segments) delays the broker's return to ISR. A second restart mid-election kills candidates and restarts the whole cycle — this is how 90 seconds becomes 20 minutes. Network partitions between controller and replicas add detection delay on top, and clients with long metadata.max.age.ms keep erroring minutes after brokers recovered because nobody told them the news.

Operate restarts like landings: one broker down at a time, verify under-replicated partitions return to zero, then proceed. Automate the verification — a deploy pipeline that restarts broker 2 while 40 partitions are still under-replicated from broker 1 is just an outage with extra steps. The election window is normal; overlapping windows are self-inflicted.

election_watch.shBASH
1
2
3
4
5
6
7
8
9
10
11
12
13
# Watch an election resolve in real time (run twice, 60s apart)
bin/kafka-topics.sh --bootstrap-server $BROKERS \
  --describe --topic payments-authorized

# Recovery gauge: trending to zero means elections are landing
watch -n 30 'bin/kafka-topics.sh --bootstrap-server $BROKERS \
  --describe --under-replicated-partitions | wc -l'

# Rolling restart the safe way: one broker, verify, next
bin/kafka-server-stop.sh  # on broker 2 only
sleep 90
bin/kafka-topics.sh --bootstrap-server $BROKERS \
  --describe --under-replicated-partitions
⚠ Unclean Election Deletes History to Restore Writes
Unclean leader election doesn't recover data — it elects a replica that lacks committed records and quietly discards them. On money topics the outage you can see is always cheaper than the data hole you can't.
📊 Production Insight
Overlapping restarts reset in-flight elections, turning 90 seconds into 20 minutes. Rule: under-replicated partitions must hit zero before the next broker bounces.
🎯 Key Takeaway
Healthy elections finish in 1-2 minutes — one broker at a time with verification between restarts keeps them that way.

Unclean Leader Election: When No ISR Survives

When no ISR replica is alive, Kafka faces a genuine dilemma: keep the partition offline (durable but unavailable) or elect an out-of-sync replica (available but lossy). The unclean.leader.election.enable flag picks the answer. False — the default and the correct choice for anything valuable — keeps leader at -1 until an ISR member returns. True elects whoever is alive, and whatever committed records they lack are gone forever.

Understand exactly what 'gone' means. The out-of-sync replica missed writes the old leader acknowledged — including records producers received success for under acks=all. After unclean election those records never come back; consumers see the log jump backward and downstream systems inherit a gap no retry can fill. One real incident lost 41 seconds of committed payments this way, and reconciliation took finance a full day.

Reserve true for genuinely expendable data: clickstreams, metrics, debug logs — topics where a gap is a shrug. Document the choice per topic in your topic registry, because the engineer flipping the flag at 3 AM won't otherwise know payments-authorized and clickstream-raw deserve opposite answers. For money topics, the correct response to leader -1 with no ISR is restoring a replica and accepting the downtime, painful as that feels mid-incident.

server.propertiesPROPERTIES
1
2
3
4
5
6
7
8
9
10
11
# Broker default (server.properties) — keep false for anything that matters
unclean.leader.election.enable=false

# Per-topic override inspection
bin/kafka-configs.sh --bootstrap-server $BROKERS \
  --entity-type topics --entity-name payments-authorized --describe

# Nuclear option for EXPENDABLE topics only (logs, metrics):
# bin/kafka-configs.sh --bootstrap-server $BROKERS \
#   --entity-type topics --entity-name clickstream-raw \
#   --alter --add-config unclean.leader.election.enable=true
📊 Production Insight
Flipping unclean election on a payments topic discarded 41s of committed writes. Rule: false everywhere that matters; true only where a gap is a shrug.
🎯 Key Takeaway
Unclean election restores writes by discarding committed records — reserve it for expendable topics and document the choice per topic.

min.insync.replicas vs acks: the Durability Contract

acks and min.insync.replicas are a pair, and misconfiguring one wastes the other. acks=all tells the producer to wait for every in-sync replica to acknowledge. min.insync.replicas sets the broker-side floor: if the ISR shrinks below it, acks=all produces fail with NotEnoughReplicas instead of risking durability. Together on RF=3 with min.insync.replicas=2, you survive one replica loss with full guarantees and fail loudly (safely) on two.

The classic misconfiguration is acks=all against min.insync.replicas=1, which pays full latency for single-replica durability — the worst of both worlds. The mirror mistake is lowering min.insync.replicas mid-incident to silence NotEnoughReplicas errors, converting a safe stall into silent single-replica writes that the next failure turns into loss.

Treat NotEnoughReplicas during an outage as protection working, not breakage. The correct response is restoring replicas (restart the downed broker, fix its disk, let it catch up) while producers retry with backoff. Monitor ISR shrink as a leading indicator: alert when under-replicated partitions stay nonzero for 5 minutes, so you start the day with a warning instead of ending it with an outage. When in doubt, page the topic owner before flipping the flag — a two-minute discussion beats a two-day reconciliation.

durability_check.shBASH
1
2
3
4
5
6
7
8
9
10
11
12
# The standard durable trio on RF=3 topics
# server.properties:
# min.insync.replicas=2
# producer: acks=all, retries=Integer.MAX_VALUE, max.in.flight.requests.per.connection=5

# Inspect effective topic config (topic overrides broker defaults)
bin/kafka-configs.sh --bootstrap-server $BROKERS \
  --entity-type topics --entity-name payments-authorized --describe

# Alert long before the breach: ISR shrink rate
# monitor: kafka.server:type=ReplicaManager,name=UnderReplicatedPartitions
# warn if UnderReplicatedPartitions > 0 for > 5 min
📊 Production Insight
acks=all with min.insync.replicas=1 charges full latency for single-replica safety. Rule: the trio (RF=3, min ISR 2, acks=all) or admit you're running best-effort.
🎯 Key Takeaway
Pair acks=all with min.insync.replicas=2 on RF=3 — and read NotEnoughReplicas as protection working, not as breakage.

preferred-replica-election: Restoring Balance

After an outage, leadership piles onto survivors. Broker 1 holds 100% of leaders while brokers 2 and 3 sit idle but healthy — and the next routine restart of broker 1 becomes a full outage because every leader lives there. Preferred-replica-election fixes this by moving each partition's leadership back to its preferred replica (the first in the replica list) once that replica is caught up.

The operation is safe by design: it only elects preferred replicas that are in sync, so no data risk attaches. Run it after every ISR recovery, not just incidents — any restart skews leadership a little, and skew compounds across months of patches until one broker secretly leads everything. The targeted JSON-file form lets you move leadership gradually during business hours if a full rebalance feels spicy.

Automate what humans forget. A 10-minute scheduler tick running preferred election (or your operator's auto-rebalance) means post-maintenance skew self-heals overnight. Verify with the leader histogram: roughly equal counts per broker is healthy, 90%-on-one is a pager waiting to happen. One command, run routinely, removes an entire class of 'routine restart becomes outage' surprises. Rehearse single-broker loss in staging quarterly so the first time you see ISR shrink is not during a real outage.

preferred_election.shBASH
1
2
3
4
5
6
7
8
9
# Restore balance after ISR recovery
bin/kafka-preferred-replica-election.sh --bootstrap-server $BROKERS

# Targeted: only the partitions that need it (from a JSON file)
# bin/kafka-preferred-replica-election.sh --bootstrap-server $BROKERS --path-to-json-file election.json

# Confirm leaders spread evenly again
bin/kafka-topics.sh --bootstrap-server $BROKERS \
  --describe --topic payments-authorized | awk '{print $6}' | sort | uniq -c
📊 Production Insight
One broker secretly led 100% of partitions for weeks until its patch restart took everything down. Rule: automate preferred election so skew never compounds.
🎯 Key Takeaway
Leadership piles onto survivors after every outage — run preferred-replica-election routinely and verify an even spread.

Verifying ISR Recovery and Client Recovery

Broker-side recovery and client-visible recovery are two different events, and incidents stay open in the gap. Producers and consumers cache metadata — including which broker leads each partition — and refresh it on metadata.max.age.ms (default 5 minutes) or on demand after errors. A client that cached the leaderless state can keep throwing LeaderNotAvailable for minutes after the partition is fully healthy.

Close the gap deliberately. Shorten metadata.max.age.ms to 30 seconds on critical clients so post-recovery refresh happens fast, and after any leader incident run an end-to-end probe: produce one record to each affected topic and consume it back. That single round trip proves more than any dashboard — it exercises metadata fetch, leader routing, produce path, ISR write, and fetch path in one shot.

Make the probe part of your runbook's definition of done. 'Topic describe shows leaders' is a broker claim; 'produce plus consume round-trips' is client proof. If the probe fails while brokers look healthy, suspect stale metadata first (restart the client or force refresh) before reopening the broker investigation. Declaring victory from broker metrics alone is how teams close incidents that are still burning.

client_verify.shBASH
1
2
3
4
5
6
7
8
9
10
11
# Client-side: refresh metadata fast during incidents
# producer/consumer config:
# metadata.max.age.ms=30000

# End-to-end proof the partition serves again
bin/kafka-console-producer.sh --bootstrap-server $BROKERS --topic payments-authorized <<'EOF'
recovery-probe-1
EOF
bin/kafka-console-consumer.sh --bootstrap-server $BROKERS \
  --topic payments-authorized --from-beginning --max-messages 1 \
  --timeout-ms 15000
📊 Production Insight
Brokers showed healthy ISR while apps errored for 9 more minutes on cached leaderless metadata. Rule: the incident ends at client proof, not broker dashboards.
🎯 Key Takeaway
Broker recovery isn't client recovery — probe with a produce/consume round trip before closing the incident.
● Production incidentPOST-MORTEMseverity: high

The Patch Restart That Ate 41 Seconds of Committed Payments

Symptom
At 2:14 AM, producers on payments-authorized threw LeaderNotAvailableException on 11 of 36 partitions; consumer fetch stalled on the same set. Topic describe showed Leader: -1 with Isr lists missing both restarted brokers. The remaining broker held 100% of live leadership, its request queue spiked to 340 pending, and checkout authorizations failed for 23 minutes — 1,180 declined checkouts.
Assumption
The on-call engineer assumed the patch had corrupted the broker, so they restarted a second broker 'to clear the error' — resetting every in-flight election. When errors persisted, they enabled unclean.leader.election.enable=true on the payments topic to 'restore writes,' which elected an out-of-sync replica and silently dropped 41 seconds of committed transactions.
Root cause
Broker 2 restarted for patching, and its 48 led partitions entered election. Before elections completed, a second broker was restarted, killing the very ISR replicas campaigning for leadership. With no in-sync replica available for 11 payments partitions, the leader field sat at -1. Enabling unclean.leader.election elected broker 3 — which was 41 seconds behind — as leader, discarding committed records the old leader held.
Fix
They reverted unclean election immediately, restored the patched broker (its logs were intact — only the process was down), and let the ISR replica catch up for 6 minutes. Then they ran kafka-preferred-replica-election.sh, restored leadership balance across all 3 brokers, and reconciled the 41-second gap from the upstream payment gateway's idempotency log. Total write outage: 23 minutes; finance signed off on the reconciliation the same day.
Key lesson
  • One broker down at a time, always — the second restart turned a 90-second election into a 23-minute outage plus a data gap.
  • Unclean leader election on a money topic is never the shortcut; 41 seconds of committed writes vanished the moment an out-of-sync replica took over.
  • Verify ISR recovery per partition and rebalance leadership afterward, or the next maintenance hits the same overloaded survivors.
Production debug guideFive checks — leader state, replication trend, durability config, leadership balance, client view — that close the incident.5 entries
Symptom · 01
LeaderNotAvailable right after a broker restart
→
Fix
Run bin/kafka-topics.sh --bootstrap-server $BROKERS --describe --topic $TOPIC and read the Leader and Isr columns per partition. Leader -1 with a shrinking Isr means election in flight — wait 60-120s and re-run. Leader -1 with every replica offline means no ISR survivor exists, and waiting won't help: move to restoring a replica.
Symptom · 02
Can't tell if recovery is progressing or wedged
→
Fix
Track under-replicated partitions as your recovery gauge: bin/kafka-topics.sh --bootstrap-server $BROKERS --describe --under-replicated-partitions | wc -l every 30 seconds. A count falling toward zero means elections are landing and replicas are catching up. A count stuck flat for 5+ minutes means the ISR can't rebuild — check broker logs for log-recovery errors or disk issues on the downed replica.
Symptom · 03
Produces fail with NotEnoughReplicas while a leader exists
→
Fix
Check the durability pair before changing it: grep -E 'min.insync.replicas|unclean.leader.election' /etc/kafka/server.properties plus kafka-configs.sh --bootstrap-server $BROKERS --entity-type topics --entity-name $TOPIC --describe. If ISR size sits below min.insync.replicas, acks=all produces fail correctly — that's protection, not breakage. Restore replicas; don't lower the floor to silence the alert.
Symptom · 04
Recovery done but all leaders sit on the survivors
→
Fix
Rebalance leadership after ISR recovery: bin/kafka-preferred-replica-election.sh --bootstrap-server $BROKERS, then re-run topic describe and confirm leaders spread across brokers instead of piling on two survivors. Schedule it on a 10-minute tick via cron or your operator so post-incident skew self-heals even when humans forget.
Symptom · 05
Brokers healthy, app still throwing LeaderNotAvailable
→
Fix
Prove clients see the new world: lower metadata.max.age.ms to 30000 on producers/consumers, then produce one test record to the affected topic and consume it back. If brokers show ISR healthy but the app still throws LeaderNotAvailable, the client cached leaderless metadata — a client restart or forced refresh clears it. Never declare victory from broker-side metrics alone.
Leader Not Available: Diagnose at a Glance
Root CauseHow to ConfirmFixPrevention
Broker restarting / election in flightUnder-replicated partitions spike then fall; leader field repopulates within 1-2 minWait, then verify ISR recovery per partitionRolling restarts with one broker down at a time
No live ISR replica (all replicas down)Leader stays -1 for minutes; replicas all offline in topic describeRestore a replica; only then consider unclean election for expendable topicsmin.insync.replicas=2 on RF=3; rack-aware assignment
min.insync.replicas vs acks mismatchProduces fail NotEnoughReplicas while leaders exist; ISR size below minimumLower produce pressure or restore replicas; align acks with durability needsAlert on ISR shrink; load-test single-broker-loss
Stale client metadata / unbalanced leadershipBrokers healthy but clients still error; leadership piled on few brokersForce metadata refresh; run preferred-replica-electionShort metadata.max.age.ms; scheduled preferred election
⚙ Quick Reference
5 commands from this guide
FileCommand / CodePurpose
election_watch.shbin/kafka-topics.sh --bootstrap-server $BROKERS \Broker Restarts and the Leader Election Timeline
server.propertiesunclean.leader.election.enable=falseUnclean Leader Election
durability_check.shbin/kafka-configs.sh --bootstrap-server $BROKERS \min.insync.replicas vs acks
preferred_election.shbin/kafka-preferred-replica-election.sh --bootstrap-server $BROKERSpreferred-replica-election
client_verify.shbin/kafka-console-producer.sh --bootstrap-server $BROKERS --topic payments-autho...Verifying ISR Recovery and Client Recovery

Key takeaways

1
Leader -1 during a restart is usually a transient election
verify with ISR trends before touching anything.
2
Only an in-sync replica can become leader without data loss; unclean election trades gaps for availability.
3
Match acks=all with min.insync.replicas=2 on RF=3, and alert on ISR shrink before it breaches.
4
Run preferred-replica-election after every recovery so leadership rebalances off survivors.
5
Never stack restarts during an election
each bounce resets the recovery you're waiting for.
6
Clients cache leaderless metadata, so force a refresh and produce-test before declaring victory.

Common mistakes to avoid

5 patterns
×

Restarting more brokers during the election window

Symptom
A 60-second leader gap turns into 20 minutes of rolling elections as each restart invalidates the ISR the previous election just built.
Fix
Wait out the election window (usually 30-120s) and confirm with metadata requests before restarting anything else. Bouncing more brokers mid-election extends the outage you were trying to shorten.
×

Enabling unclean leader election to 'reduce downtime'

Symptom
Producers succeed during the outage but committed records vanish afterward. Consumers see time go backward — duplicates are replaced by permanent gaps.
Fix
Keep unclean.leader.election.enable=false on any topic where correctness matters, and size min.insync.replicas so a single broker loss can't wedge you. Accept unavailability over silent data loss.
×

Running acks=all against min.insync.replicas=1

Symptom
You pay full all-replicas latency for single-replica durability. The first real broker failure still risks the exact loss you thought you'd prevented.
Fix
Set acks=all with min.insync.replicas=2 on a 3-replica topic, and alert on ISR shrink rate so you know you're one failure from a stall before it happens.
×

Never running preferred-replica-election after recovery

Symptom
All leadership sits on two survivors for weeks. The next maintenance takes down the only leaders you have left, and a routine restart becomes an outage.
Fix
Run bin/kafka-preferred-replica-election.sh after every restart and automate it on a 10-minute scheduler tick. Verify partition leadership spreads evenly instead of piling on survivors.
×

Trusting stale client metadata after ISR recovery

Symptom
Brokers show healthy ISR while producers still throw LeaderNotAvailable. The client cached the leaderless state and never re-fetched.
Fix
Set metadata.max.age.ms lower (e.g. 30s) on clients and confirm fresh metadata with a produce test to the affected topic. Don't trust a cached leader field older than the incident.
INTERVIEW PREP · PRACTICE MODE

Interview Questions on This Topic

Q01JUNIOR
What does LeaderNotAvailableException mean?
Q02SENIOR
How do you tell a normal election from a stuck one?
Q03SENIOR
Why do produces fail with NotEnoughReplicas when a leader exists?
Q04SENIOR
When is unclean leader election acceptable, and what does it cost?
Q05SENIOR
ISR looks healthy but writes still fail. What are your three suspects?
Q01 of 05JUNIOR

What does LeaderNotAvailableException mean?

ANSWER
It means the partition currently has no leader — usually a broker restarted and an election is in flight, or no in-sync replica is alive. Producers can't append and consumers can't fetch from that partition until a new leader is elected.
FAQ · 6 QUESTIONS

Frequently Asked Questions

01
How long should leader election take?
02
Can unclean leader election lose committed data?
03
What's the difference between acks and min.insync.replicas?
04
Is preferred-replica-election safe to run in production?
05
Brokers recovered but my app still errors — why?
06
Leader -1 vs UnknownTopicOrPartition — different?
N
Naren Founder & Principal Engineer

20+ years shipping production backend systems. Everything here is grounded in real deployments.

Follow
✓ Verified
production tested
September 27, 2026
last updated
2,085
articles · all by Naren
🔥

That's Kafka. Mark it forged?

5 min read · try the examples if you haven't

←
Previous
Kafka Consumer Lag Growing but CPU Idle
2 / 4 · Kafka
Next
Kafka RecordTooLargeException
→