Kafka Common Errors
The exception name is only the starting point. Always retain the complete message, cause chain, client ID, broker or coordinator ID, topic-partition, correlation ID, and timestamp.
Decide Whether to Retry
Section titled “Decide Whether to Retry”Kafka protocol errors and client-side exceptions are related but not identical. A Java exception that extends RetriableException is eligible for automatic retry, subject to the operation’s timeout and client state. Retriable does not mean harmless or guaranteed to succeed.
| Class of failure | Typical response |
|---|---|
| Transient leader, coordinator, or network change | Let the client refresh metadata and retry within its configured budget |
| Authorization, authentication, or invalid configuration | Correct identity, ACLs, or configuration; repeated retries add load |
| Producer or member fencing | Close the stale instance and establish ownership; do not loop on the fenced client |
| Unknown write outcome | Use idempotence or transactions and application-level deduplication; do not assume the write failed |
| Corruption or storage failure | Isolate the affected replica or directory and preserve evidence |
Consult the wire-protocol error reference for the complete released error-code table. This page focuses on operational interpretation.
Connection and Metadata Errors
Section titled “Connection and Metadata Errors”TimeoutException
Section titled “TimeoutException”TimeoutException is a boundary, not a root cause. Read the complete message.
| Message or context | Common cause | Next check |
|---|---|---|
| Timed out waiting for a node assignment | No usable broker connection | DNS, TLS/SASL, advertised listeners |
| Topic not present in metadata | Missing topic, no leader, ACL denial, or metadata cannot refresh | Topic state, broker logs, ACLs |
Failed to allocate memory within max.block.ms | Producer buffer exhausted or metadata unavailable | buffer wait metrics, send rate, broker reachability |
Expiring records after delivery.timeout.ms | Produce requests did not complete inside the delivery budget | request latency, retries, ISR, throttling |
| Admin operation timed out | Controller, broker, or network did not complete the operation | quorum health, request metrics, controller logs |
Do not increase all timeouts at once. Identify whether time was spent in DNS, connection setup, metadata discovery, the client buffer, the broker queue, replication, or throttling.
BootstrapResolutionException
Section titled “BootstrapResolutionException”Kafka 4.4 Java clients can resolve bootstrap DNS asynchronously when bootstrap.resolve.timeout.ms is positive. This exception means no bootstrap address resolved before that deadline.
Check DNS from the client network namespace, resolver latency and search domains, A/AAAA reachability, and the literal bootstrap names. This setting does not affect DNS failures for broker names returned later in metadata. Kafka Streams and Kafka Connect keep synchronous bootstrap resolution.
NetworkException and DisconnectException
Section titled “NetworkException and DisconnectException”These are normally retried, but repetition indicates a real fault. Check broker restarts, load balancer idle timeouts, TLS re-authentication, connection quotas, packet loss, NAT exhaustion, and broker request-handler saturation.
UnknownTopicOrPartitionException
Section titled “UnknownTopicOrPartitionException”This error is retriable because metadata can be temporarily stale. Persistent occurrences mean one of the following:
- the topic or partition does not exist;
- topic creation has not completed;
- the client cannot describe the topic because of ACLs;
- the broker has stale metadata or cannot follow the controller;
- the application uses the wrong cluster or topic name.
kafka-topics.sh --bootstrap-server kafka:9092 \ --describe --topic ordersNotLeaderOrFollowerException and LeaderNotAvailableException
Section titled “NotLeaderOrFollowerException and LeaderNotAvailableException”These are expected briefly during leader movement. Persistent errors require checks for offline partitions, broker registration, controller health, and client reachability to the newly advertised leader.
kafka-topics.sh --bootstrap-server kafka:9092 \ --describe --unavailable-partitionsProducer Errors
Section titled “Producer Errors”NotEnoughReplicasException
Section titled “NotEnoughReplicasException”The ISR was smaller than min.insync.replicas before the append. The record was rejected.
kafka-topics.sh --bootstrap-server kafka:9092 \ --describe --topic orderskafka-topics.sh --bootstrap-server kafka:9092 \ --describe --under-min-isr-partitionsRestore failed or lagging replicas. Lowering min.insync.replicas reduces the durability of acknowledged writes and is an explicit incident tradeoff, not the default repair.
NotEnoughReplicasAfterAppendException
Section titled “NotEnoughReplicasAfterAppendException”The leader appended the record, but the ISR fell below the required size before the acknowledgement completed. The client does not know whether the write became visible. Idempotent producers can retry without creating a duplicate within the producer session. Non-idempotent applications need a business-level deduplication strategy.
RecordTooLargeException and RecordBatchTooLargeException
Section titled “RecordTooLargeException and RecordBatchTooLargeException”Validate every size boundary in the path:
- producer
max.request.size; - topic
max.message.bytesor brokermessage.max.bytes; - follower
replica.fetch.max.bytes; - consumer
max.partition.fetch.bytesandfetch.max.bytes; - intermediary limits in proxies, Connect, or schema tooling.
Compression does not make an oversized uncompressed record safe at every stage. Prefer a payload reference or chunking design for genuinely large objects.
SerializationException
Section titled “SerializationException”Producer serialization failed before a valid record was sent. Capture the serializer class, schema ID or version, record type, and cause. Do not log confidential payloads merely to diagnose the failure.
ProducerFencedException
Section titled “ProducerFencedException”Another producer initialized with the same transactional.id, or the current instance otherwise lost ownership. This is fatal for that producer instance. Close it; do not continue sending or committing.
Use a stable but unique transactional ID per logical producer instance. During failover, fencing the old owner is expected and protects exactly-once semantics.
InvalidProducerEpochException and OutOfOrderSequenceException
Section titled “InvalidProducerEpochException and OutOfOrderSequenceException”These indicate stale producer state or a broken ordering/session assumption. Modern idempotent producers normally recover internally where safe. If the exception reaches the application as fatal, close and recreate the producer, then investigate duplicate instances, unsupported custom retry logic, broker/client compatibility, and transaction recovery.
AuthorizationException
Section titled “AuthorizationException”Authorization exceptions are fatal for the affected operation and are not solved by retries. Map the operation to its resource:
| Operation | Common required resources |
|---|---|
| Produce | Topic WRITE and usually DESCRIBE |
| Idempotent produce | Cluster IDEMPOTENT_WRITE where required by the authorization model |
| Transactional produce | Transactional ID WRITE and topic permissions |
| Create or alter topics | Cluster/topic create or alter permissions |
Consumer-Group Errors
Section titled “Consumer-Group Errors”OffsetOutOfRangeException
Section titled “OffsetOutOfRangeException”The requested offset is earlier than the log start offset or later than the log end offset. Common causes are retention, topic recreation, offset restore errors, or an application seeking to a bad value.
Choose intentionally between replay and skipping. Stop the group, preview the reset, and retain the plan:
kafka-consumer-groups.sh --bootstrap-server kafka:9092 \ --group orders-consumer \ --topic orders \ --reset-offsets --to-earliest --dry-runauto.offset.reset is used when no valid initial position exists; changing it does not rewrite an already valid committed offset.
NoOffsetForPartitionException
Section titled “NoOffsetForPartitionException”No committed offset exists and auto.offset.reset=none. Either establish an offset through an approved reset or choose earliest/latest for the application’s first-start policy. Confirm that this is not a new group ID caused by a deployment typo.
CommitFailedException
Section titled “CommitFailedException”The consumer no longer owns the partitions under the generation or member epoch used for the commit. Check:
- processing exceeded
max.poll.interval.ms; - the process paused, crashed, or lost network connectivity;
- static members reuse the same
group.instance.id; - coordinator or broker instability caused repeated rejoins;
- application code commits from the wrong thread or after partition revocation.
For consume-transform-produce transactions, abort the transaction, poll to obtain current group metadata, and retry the processing loop. Kafka 4.4’s transactional offset-commit protocol can surface more precise group errors; do not collapse them into a blind commit retry.
RebalanceInProgressException
Section titled “RebalanceInProgressException”The group is changing membership or assignment. A short occurrence is normal. Repetition indicates member churn, long poll gaps, slow rebalance callbacks, coordinator instability, incompatible assignors, or frequent deployments.
FencedInstanceIdException and UnreleasedInstanceIdException
Section titled “FencedInstanceIdException and UnreleasedInstanceIdException”The static instance ID is owned by another live or not-yet-released member. Ensure each simultaneously running instance has a unique group.instance.id. During replacement, let the prior member leave or expire before reusing the ID.
FencedMemberEpochException
Section titled “FencedMemberEpochException”The broker-side consumer protocol rejected a stale member epoch. The member must abandon its assignment and rejoin. Repeated fencing suggests stale concurrent instances, connection churn, coordinator movement, or faulty client lifecycle handling.
Deserialization Failures
Section titled “Deserialization Failures”RecordDeserializationException identifies the topic-partition and offset that failed. Apache Kafka clients do not provide a universal poison-pill handler. Application or framework code must choose among:
- stopping and fixing the schema or deserializer;
- recording the raw bytes and metadata to an application-managed DLQ;
- seeking past the record with explicit audit and data-loss handling;
- routing through a framework-specific error handler.
Do not present framework classes as built-in Kafka APIs. Preserve key/value bytes carefully because they may contain sensitive data.
Share-Group Errors
Section titled “Share-Group Errors”ShareSessionNotFoundException
Section titled “ShareSessionNotFoundException”The broker no longer has the client’s share-fetch session. The client normally creates a new session. If it repeats, check connection churn, coordinator movement, client lifecycle, and broker session limits.
InvalidShareSessionEpochException
Section titled “InvalidShareSessionEpochException”The client and broker disagree on the share-session epoch. Re-establish the session. Persistent errors suggest stale concurrent requests, a client compatibility problem, or unstable connections.
ShareSessionLimitReachedException
Section titled “ShareSessionLimitReachedException”The broker reached its share-session limit. Check abandoned sessions, client churn, group concurrency, broker capacity, and the relevant session-limit configuration before raising the limit.
FencedStateEpochException
Section titled “FencedStateEpochException”The share coordinator rejected a stale state epoch. Refresh group state and retry only through the supported client flow. Investigate repeated coordinator changes or stale administrative operations.
Acknowledgement and DLQ Failures
Section titled “Acknowledgement and DLQ Failures”An acknowledgement error can cause release or redelivery depending on client and broker state. Capture the acknowledgement type, delivery attempt, acquisition-lock timing, and partition. For Kafka 4.4 broker-managed DLQs, verify share.version=2, group DLQ settings, topic existence/configuration, broker authorization, and DLQ write metrics.
Authentication and Authorization Errors
Section titled “Authentication and Authorization Errors”SaslAuthenticationException
Section titled “SaslAuthenticationException”Check the mechanism on both ends, principal and password/keytab, JAAS context, SCRAM credential location, Kerberos clock/DNS, OAuth token claims, and listener-specific SASL settings. Repeated authentication retries can trigger connection quotas or lockouts.
SslAuthenticationException
Section titled “SslAuthenticationException”The TLS handshake or certificate validation failed. Inspect the nested SSL exception for unknown CA, hostname mismatch, expiry, protocol mismatch, missing client certificate, or algorithm constraints.
TopicAuthorizationException, GroupAuthorizationException, and TransactionalIdAuthorizationException
Section titled “TopicAuthorizationException, GroupAuthorizationException, and TransactionalIdAuthorizationException”The authenticated principal lacks an operation on the named resource. List ACLs using an authorized administrative identity and consider resource patterns and host restrictions. Do not grant broad wildcard ACLs merely to prove that authorization is the cause; reproduce with the minimum intended permissions.
KRaft and Broker Startup Errors
Section titled “KRaft and Broker Startup Errors”InconsistentClusterIdException
Section titled “InconsistentClusterIdException”The process is attempting to join a different cluster from the one recorded locally or returned by the controller. Confirm the intended cluster, configuration, and meta.properties. Do not edit the cluster ID or reformat a directory until you have established whether it contains required data.
DuplicateBrokerRegistrationException
Section titled “DuplicateBrokerRegistrationException”The node.id is already registered to another active broker incarnation. Check for a duplicate deployment, cloned volume, stale process, or reused identity. Each concurrently running broker and controller requires a unique node ID.
Directory-ID or meta.properties Errors
Section titled “Directory-ID or meta.properties Errors”These commonly follow partial disk replacement, copied data directories, or incorrect storage formatting. Run:
kafka-storage.sh info -c config/broker.propertiesCompare every configured log directory. Preserve healthy directories and metadata. Follow the broker or directory replacement procedure rather than manually inventing IDs.
Quorum Has No Leader
Section titled “Quorum Has No Leader”This is normally a connectivity, voter-majority, metadata-storage, or long-pause problem rather than a topic problem.
kafka-metadata-quorum.sh \ --bootstrap-controller controller1:9093 \ describe --statuskafka-metadata-quorum.sh \ --bootstrap-controller controller1:9093 \ describe --replicationRestore a majority. Do not delete the metadata log or format controllers as an exploratory action.
Storage Errors
Section titled “Storage Errors”KafkaStorageException and LogDirFailureException
Section titled “KafkaStorageException and LogDirFailureException”Check kernel logs, disk and inode capacity, mount state, permissions, filesystem health, device latency, and Kafka’s log-directory status. Preserve the exception and affected directory ID.
kafka-log-dirs.sh --bootstrap-server kafka:9092 --describedf -hdf -ijournalctl -k --since "30 minutes ago"Do not run fsck on a mounted filesystem, delete Kafka files while the broker is running, or copy arbitrary segments into another live replica.
CorruptRecordException
Section titled “CorruptRecordException”The error can describe a bad CRC, invalid size, null key in a compacted topic, or other invalid record structure. Determine whether the corruption exists on disk, in transit, or in producer output. Compare replicas, preserve the segment, and inspect a copy with kafka-dump-log.sh. Avoid printing payloads unless access controls permit it.
Kafka Connect and Streams Errors
Section titled “Kafka Connect and Streams Errors”For Kafka Connect, a FAILED task status includes a trace that is often more useful than the top-level worker log. Capture it before restarting:
curl -sS http://connect.example.com:8083/connectors/orders-sink/statusSeparate converter/schema errors, plugin-loading failures, source/sink failures, authorization, and internal-topic health.
For Kafka Streams, distinguish fatal client errors, replace-thread responses, task migration, state restore, RocksDB/storage faults, and transaction fencing. Capture the application ID, task ID, state directory, changelog partition, thread state, and configured uncaught-exception response.
What to Record
Section titled “What to Record”For any recurring error, record:
- exact first and last occurrence in UTC;
- frequency and whether retries eventually succeed;
- client and server versions;
- client ID, principal, broker/coordinator ID, topic-partition, group, and transactional ID where applicable;
- the complete exception chain;
- related metrics, broker/controller logs, and recent changes;
- whether the operation has an unknown outcome;
- every mitigation already applied.