Kafka Exception UnknownProducerIdException
org.apache.kafka.common.errors.UnknownProducerIdException
Non-retriable
Producer
This exception is raised by the broker if it could not locate the producer metadata associated with the producerId in question. This could happen if, for instance, the producer's records were deleted because their retention time had elapsed. Once the last records of the producerId are removed, the producer's metadata is removed from the broker, and future appends by the producer will return this exception.
Reviewed 2026-10-27 · 4.4.0 · source-reviewed. Source
Common Causes
- The broker no longer has the producer state needed to validate the batch; retention, log truncation or state expiry can be involved.
Solutions
- Inspect the final delivery result and client logs. Kafka Java 4.4 handles several UNKNOWN_PRODUCER_ID cases internally with sequence resets or epoch changes; do not recreate the producer on every logged response.
- If the error escapes to application code, follow the client transaction/error contract. Re-sending records through a new producer session can duplicate writes whose outcome was ambiguous.
Example Stack Trace
org.apache.kafka.common.errors.UnknownProducerIdException: This exception is raised by the broker if it could not locate the producer metadata associated with the producerId in question. This could happen if, for instance, the producer's records were deleted because their retention time had elapsed. Once the last records of the producerId are removed, the producer's metadata is removed from the broker, and future appends by the producer will return this exception.Diagnostic Commands
# Look for related errors in broker logs
grep 'UNKNOWN_PRODUCER_ID\|UnknownProducerIdException\|ProducerStateManager' /path/to/kafka/logs/server.log | tail -30
# Check topic retention and cleanup settings
kafka-configs.sh --bootstrap-server localhost:9092 --entity-type topics --entity-name <topic> --describe | grep -E 'retention|cleanup.policy|min.compaction.lag|max.compaction.lag'Related
Protocol error: UNKNOWN_PRODUCER_ID (code 59)
Related Producer exceptions: BufferExhaustedException · InvalidProducerEpochException · OutOfOrderSequenceException · RecordBatchTooLargeException · RecordTooLargeException · TransactionAbortedException · UnsupportedForMessageFormatException
Hitting
UnknownProducerIdException in production? Conduktor Console gives you real-time visibility into clients, consumer groups, and broker health. Browse every Kafka exception or protocol error code.