Kafka Exception FencedInstanceIdException
org.apache.kafka.common.errors.FencedInstanceIdException
Non-retriable
Consumer
FencedInstanceIdException is a Kafka exception (org.apache.kafka.common.errors.FencedInstanceIdException).
Common Causes
- Two consumer instances were started with the same group.instance.id (static membership), causing the broker to fence the older one when the newer one joins
- A consumer crashed and restarted with the same group.instance.id before the session timeout expired, and a duplicate was already registered
- Kubernetes or container orchestration created a duplicate pod with the same static instance ID due to a misconfigured StatefulSet or deployment
Solutions
- Ensure each consumer instance has a unique, stable group.instance.id — typically derived from the pod name or hostname in Kubernetes (e.g., MY_APP_POD_NAME env var)
- After a crash, wait for the member session timeout to expire before restarting with the same instance ID, or shut the old member down cleanly so it sends LeaveGroup before the replacement starts
- In Kubernetes, use the StatefulSet pod ordinal as part of the instance ID to guarantee uniqueness across restarts
Example Stack Trace
org.apache.kafka.common.errors.FencedInstanceIdException: The broker rejected this static consumer since another consumer with the same group.instance.id has registered with a different member.id.Diagnostic Commands
# Check group members for the instance ID
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group <group-id> | grep <instance-id>
# Search all groups for a specific instance ID
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --list | xargs -I{} kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group {} 2>/dev/null | grep <instance-id>Related
Protocol error: FENCED_INSTANCE_ID (code 82)
Related Consumer exceptions: CommitFailedException · CoordinatorLoadInProgressException · CoordinatorNotAvailableException · FencedMemberEpochException · GroupMaxSizeReachedException · IllegalGenerationException · InvalidGroupIdException · InvalidOffsetException
Hitting
FencedInstanceIdException in production? Conduktor Console gives you real-time visibility into clients, consumer groups, and broker health. Browse every Kafka exception or protocol error code.