Troubleshooting Kafka: Common Problems, Diagnosis Steps and Fixes

Apache Kafka 19 min min read Updated: Nov 17, 2026 Advanced
Troubleshooting Kafka: Common Problems, Diagnosis Steps and Fixes
Advanced Topic 2 of 3

A General Method

  1. What changed? Deployment, config change, traffic spike, certificate expiry, network change, broker restart
  2. Scope: one client, one topic, one broker or the whole cluster?
  3. Check cluster health: controller, offline and under-replicated partitions, broker logs, disk space
  4. Check the client: error messages, client logs with timestamps, client metrics
  5. Mitigate first, fix root cause later: restart a stuck consumer, move traffic, free disk, throttle a noisy client
  6. Write down timeline and cause for the post-incident review

First Commands

bash bin/kafka-metadata-quorum.sh --bootstrap-server $BS describe --status # controller quorum bin/kafka-topics.sh --bootstrap-server $BS --describe --under-replicated-partitions bin/kafka-topics.sh --bootstrap-server $BS --describe --unavailable-partitions bin/kafka-consumer-groups.sh --bootstrap-server $BS --describe --group my-group --state df -h /var/lib/kafka ; free -m ; iostat -x 1 3 ; ss -tnlp | grep 9092 sudo journalctl -u kafka --since "30 min ago" | grep -E "ERROR|WARN" | tail -50

Problem 1: Client Cannot Connect or Times Out

SymptomCauseFix
Bootstrap connection works, then Connection to node 1 (localhost/127.0.0.1:9092) could not be establishedBroker advertises an address clients cannot reach (advertised.listeners=localhost)Set advertised.listeners to a real hostname or IP reachable from clients. In Docker or Kubernetes use separate internal and external listeners
TimeoutException: Topic not present in metadataTopic missing (auto-create disabled), wrong name, ACL denies Describe, or no connectivityCreate the topic, check name and ACLs
UnknownHostExceptionDNS cannot resolve the advertised hostnameFix DNS or /etc/hosts on clients
TLS errorsCertificate, SAN, truststore problemsSee the security lesson
Works from one network onlyFirewall, security groups, load balancer between client and brokerOpen broker ports to the client subnet. Do not place a plain TCP load balancer in front of individual brokers without per-broker listeners
text # Kubernetes / Docker pattern with two listeners listeners=INTERNAL://:9092,EXTERNAL://:9094 advertised.listeners=INTERNAL://kafka-0.kafka.svc:9092,EXTERNAL://kafka-0.public.example.com:9094 listener.security.protocol.map=INTERNAL:SASL_SSL,EXTERNAL:SASL_SSL,CONTROLLER:SASL_SSL inter.broker.listener.name=INTERNAL

Problem 2: Producer Errors

ErrorCauseFix
NotEnoughReplicasException / NotEnoughReplicasAfterAppendExceptionISR smaller than min.insync.replicasFind the failed or slow broker, restore ISR. Do not lower min.insync.replicas as a quick fix for important data
TimeoutException: Expiring N record(s) ... delivery timeoutBroker slow or unreachable, leader election, buffer too smallCheck broker health, network, increase delivery.timeout.ms only if needed
RecordTooLargeExceptionMessage above limitsReduce size, or raise max.request.size (producer), message.max.bytes (broker/topic) and fetch limits for consumers consistently
TopicAuthorizationExceptionMissing ACLAdd Write and Describe ACLs
OutOfOrderSequenceExceptionBroker lost producer state (retention of transactional/idempotent state, or unclean election)Check for unclean leader election and data loss events, restart the producer
BufferExhaustedException / blocked send()Producing faster than the broker acceptsIncrease buffer.memory, batching, add partitions or brokers, apply backpressure

Problem 3: Consumers Not Making Progress

SymptomCheckFix
Lag grows on all partitionsProcessing time per record, downstream slownessScale consumers (up to partitions), batch downstream writes, fix the slow dependency
Lag grows on one partitionHot key or stuck recordCheck partition sizes, look at the consumer log for repeated errors on one offset
Group in PreparingRebalance or frequent rebalancesLogs show poll interval or session timeout eventsLower max.poll.records, raise max.poll.interval.ms, use cooperative or static membership
Consumer reads nothingauto.offset.reset=latest, wrong group, ACL on group missingCheck group state and ACLs, reset offsets deliberately
Stuck forever on the same offsetPoison message and an error loopSkip with a dead-letter handler, or reset the offset past it after investigation
OffsetOutOfRangeExceptionCommitted offset was deleted by retention (consumer was down too long)Reset to earliest or latest based on business rules, consider longer retention or alerts on lag

Problem 4: Disk Full

  1. Stop the growth: pause the biggest producers or add quota, reduce retention.ms on the largest non-critical topics (dynamic config)
  2. Check which topics use space: kafka-log-dirs.sh --describe
  3. Look for compacted topics that cannot compact (dirty ratio), huge __consumer_offsets or transaction topics, and old segments kept by the active segment rule
  4. Add disk or move partitions to other brokers (throttled reassignment)
  5. Prevent: alerts at 70 and 85 percent, retention limits per topic, capacity reviews
Never delete segment files by hand while the broker runs: Deleting files in a partition folder can corrupt the log. Use retention settings or the supported tools instead. A full disk can crash the broker, and recovery after an unclean shutdown can take a long time.

Problem 5: Under-Replicated or Offline Partitions

CauseEvidenceFix
A broker is downBroker process missing, logs show shutdown or crashRestart, investigate crash reason (OOM, disk, power)
Follower too slowIsrShrinks, high disk or network usage on that brokerFix I/O or network, raise num.replica.fetchers, throttle reassignment traffic
Long GC pausesGC log shows multi-second pauses, ZK/controller session timeoutsTune heap and GC, reduce partitions per broker
Overloaded clusterRequest handler idle percentage lowAdd brokers, spread partitions, reduce load
All ISR members gonePartition has no leaderBring back an ISR replica. Unclean election only as a last, data-loss-accepting decision

Problem 6: Broker Does Not Start

Log messageMeaning
No readable meta.properties files foundStorage not formatted, or wrong log.dirs
Cluster ID mismatchDirectory belongs to a different cluster
java.io.IOException: Too many open filesRaise nofile limits
java.lang.OutOfMemoryError: Map failedRaise vm.max_map_count
Corrupt index found and recovery taking longUnclean shutdown, broker is rebuilding indexes. Wait, and plan graceful shutdowns
Failed to ... the controller quorumController listener, voters list or firewall wrong

Problem 7: Duplicates, Missing or Out-of-Order Data

  • Duplicates: at-least-once delivery. Make consumers idempotent, enable producer idempotence
  • Missing data: check acks, unclean elections, retention (data deleted before read), consumer committed too early, wrong auto.offset.reset
  • Out of order: different keys go to different partitions. Same key must be same partition. Check retries with max.in.flight above 1 without idempotence, and producers using multiple threads with different keys

Incident Runbook Template

StepQuestion
DetectWhich alert fired? Who is affected? Since when?
AssessCluster, topic, group or client? Data at risk?
MitigateSmallest safe action that stops customer impact
FixRoot cause change, tested in staging when possible
VerifyMetrics back to normal, lag drained, no data gaps
LearnBlameless review: timeline, cause, what monitoring or automation would catch it earlier

Conclusion

Troubleshoot Kafka with a method: look at cluster health first, then the client, then the infrastructure. Most issues are wrong advertised listeners, under-replicated partitions, slow consumers, rebalances, full disks or security misconfiguration.

Quick Summary: advertised.listeners; ISR/URP; poll interval + rebalance; disk alerts; method: what changed, scope, mitigate.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators