How to reset offsets to arbitrary value in Kafka Consumer Group?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
Kafka lets you reset committed consumer group offsets to an arbitrary value, but it is an administrative operation that should be done carefully. The usual tools are the kafka-consumer-groups.sh CLI for manual resets and the Admin API for programmatic resets, and in both cases the group must be inactive or empty before the change can succeed.
The CLI Tool for Manual Resets
The standard operational tool is kafka-consumer-groups.sh with --reset-offsets. Kafka's current operations guide recommends previewing the change first, then applying it with --execute.
To reset one partition to an exact offset:
That command previews the change. To actually apply it, add --execute.
Resetting Multiple Partitions
If each partition should move to a different arbitrary offset, use the --from-file scenario with a CSV file. This is the best fit when a simple single offset is not enough.
Then run:
Kafka's reset-offsets tooling supports this specifically for arbitrary per-partition resets.
Always Stop the Consumers First
This is the most important operational rule. Kafka's docs state that consumer instances must be inactive before reset operations are performed. If the group is still active, the reset may fail or the running consumers may immediately overwrite the offsets again.
A good sequence is:
- stop the consumers
- describe the group and confirm it is inactive or empty
- preview the reset
- execute the reset
- restart the consumers
Programmatic Reset With the Admin API
If you need to automate offset changes, use the Kafka Admin client. The Admin API exposes alterConsumerGroupOffsets, and the current Javadoc states that the group must be empty for the operation to succeed.
This is useful for internal admin tools or controlled recovery workflows.
Previewing and Safety Checks
Before executing a reset, inspect current offsets and lag:
Also verify that the target offsets make sense for the topic retention window. Kafka will clamp out-of-range reset requests to available boundaries in some scenarios, so do not assume the request always lands exactly where you imagined without checking the output.
Resetting to Logical Positions Versus Arbitrary Numbers
Kafka also supports non-arbitrary reset modes such as:
- '
--to-earliest' - '
--to-latest' - '
--shift-by' - '
--to-datetime' - '
--by-duration'
Those are useful, but when the question is "reset to this exact offset number," the correct tools are --to-offset and --from-file.
Common Pitfalls
The biggest pitfall is trying to reset offsets while consumers are still running. Even if the command appears to work, the active group can immediately race against your administrative change.
Another issue is resetting one partition and forgetting that the consumer group spans multiple partitions. A partial reset may produce confusing replay behavior if the other partitions remain at old offsets.
Developers also forget to preview the reset before executing it. The dry-run style output is there for a reason, and it is much cheaper than replaying the wrong data range.
Finally, do not confuse auto.offset.reset with manual administrative reset. auto.offset.reset only applies when no committed offset exists or the stored offset is invalid.
Summary
- Use
kafka-consumer-groups.sh --reset-offsetsfor manual offset resets. - Use
--to-offsetfor a single exact value and--from-filefor arbitrary per-partition values. - Stop consumers first so the group is inactive or empty before resetting.
- Use the Admin API
alterConsumerGroupOffsetsfor programmatic control. - Preview the reset and verify the new offsets before restarting the group.

