# org.apache.kafka.common.errors.OffsetCommitRejectedException: Offset commit rejected due to fenced epoch

- **ID:** `kafka/offset-commit-rejected-fenced`
- **Domain:** kafka
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 82%

## Root Cause

Consumer group coordinator rejected offset commit because the consumer's epoch is stale due to a newer consumer instance taking over.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.5.0 | active | — | — |
| 3.6.0 | active | — | — |

## Workarounds

1. **Ensure unique group.instance.id per consumer instance to avoid epoch conflicts; use UUID-based IDs.** (90% success)
   ```
   Ensure unique group.instance.id per consumer instance to avoid epoch conflicts; use UUID-based IDs.
   ```
2. **Catch OffsetCommitRejectedException and rejoin the group with a fresh consumer instance.** (85% success)
   ```
   Catch OffsetCommitRejectedException and rejoin the group with a fresh consumer instance.
   ```
3. **Set 'group.protocol' to 'consumer' and disable static membership by removing group.instance.id.** (80% success)
   ```
   Set 'group.protocol' to 'consumer' and disable static membership by removing group.instance.id.
   ```

## Dead Ends

- **** — Manual commit still uses same epoch; coordinator rejects if epoch is fenced. (85% fail)
- **** — Longer interval delays rebalance but does not fix epoch fencing from duplicate consumers. (70% fail)
- **** — Deleting offsets resets group but does not prevent future fencing if same consumer ID is used. (60% fail)
