Skip to content

/codes/kafka/kafka-error-codes

Kafka error codes: UNKNOWN_TOPIC_OR_PARTITION, NOT_LEADER and more

The commands on this page have not been executed by our verification runner yet.updated 2026-10-20
tool
Apache Kafka
versions
Apache Kafka 3.x – 4.x
os
any

Kafka brokers answer every failed request with a numeric error code, and clients turn it into an exception such as UnknownTopicOrPartitionException. Code 0 means no error and -1 an unexpected server error. Many codes are retriable (the client retries automatically, for example during a leader election); others need a configuration or permission fix.

Common codes

Codes and messages from the Errors enum in the Apache Kafka source:

CodeNameMeaning
-1UNKNOWN_SERVER_ERRORThe server experienced an unexpected error when processing the request.
0NONENo error.
1OFFSET_OUT_OF_RANGEThe requested offset is not within the range of offsets maintained by the server.
2CORRUPT_MESSAGECRC check failed, invalid size, null key on a compacted topic, or otherwise corrupt.
3UNKNOWN_TOPIC_OR_PARTITIONThis server does not host this topic-partition.
5LEADER_NOT_AVAILABLEThere is no leader for this topic-partition as a leadership election is in progress.
6NOT_LEADER_OR_FOLLOWERThe broker is not the current leader for a leader-only request.
7REQUEST_TIMED_OUTThe request timed out.
10MESSAGE_TOO_LARGEThe message is larger than the maximum size the server accepts.
13NETWORK_EXCEPTIONThe server disconnected before a response was received.
15COORDINATOR_NOT_AVAILABLEThe coordinator is not available.
16NOT_COORDINATORThis is not the correct coordinator.
19NOT_ENOUGH_REPLICASRejected: fewer in-sync replicas than required.
22ILLEGAL_GENERATIONSpecified group generation id is not valid.
25UNKNOWN_MEMBER_IDThe coordinator is not aware of this member.
27REBALANCE_IN_PROGRESSThe group is rebalancing, so a rejoin is needed.
29TOPIC_AUTHORIZATION_FAILEDTopic authorization failed.
30GROUP_AUTHORIZATION_FAILEDGroup authorization failed.
35UNSUPPORTED_VERSIONThe version of API is not supported.
36TOPIC_ALREADY_EXISTSTopic with this name already exists.
38INVALID_REPLICATION_FACTORReplication factor is below 1 or larger than the number of available brokers.
58SASL_AUTHENTICATION_FAILEDSASL authentication failed.
89THROTTLING_QUOTA_EXCEEDEDThe throttling quota has been exceeded.
100UNKNOWN_TOPIC_IDThis server does not host this topic ID.

What to do

  • 3 UNKNOWN_TOPIC_OR_PARTITION: the topic does not exist (and auto-creation is off) or metadata is stale. Create the topic or check its name.
  • 5 / 6 leader errors: transient during broker restarts and elections; producers retry. Persistent errors mean a broker is down.
  • 10 MESSAGE_TOO_LARGE: raise max.request.size (producer) together with message.max.bytes (broker) or the topic's max.message.bytes, or compress and split messages.
  • 19 NOT_ENOUGH_REPLICAS: fewer in-sync replicas than min.insync.replicas while the producer uses acks=all; bring brokers back or lower the setting.
  • 27 REBALANCE_IN_PROGRESS / 25 UNKNOWN_MEMBER_ID: consumers took longer than max.poll.interval.ms between polls; process faster or raise the interval.

Sources