Warren
Error

PRECONDITION_FAILED - unknown delivery tag: why RabbitMQ closes the channel, and the duplicates it causes

2026-10-19 · 2 min read · Viktor Baumann

PRECONDITION_FAILED - unknown delivery tag 1

The channel is closed and the consumer reconnects. Annoying, but harmless? Not quite: the error has a side effect that turns into duplicate processing. Measured on RabbitMQ 4.3.6.

What the error means

A delivery tag is a number the broker gives each message it hands to a channel. It is only valid on that channel, and only until the message is acknowledged. An ack, nack or reject with a tag the channel does not know closes the channel. We triggered it three ways:

What the code didResult
acked the same message twiceunknown delivery tag
fetched with auto_ack=True, then ackedunknown delivery tag: with auto-ack there is nothing left to ack
acked on a different channel of the same connectionunknown delivery tag: tags are per channel

In frameworks the double ack usually comes from two places acking the same message: the framework acks after the handler returns, and the handler acks itself as well. Spring AMQP's default acknowledge mode, for example, acks for you; a manual channel.basicAck in the listener on top of that is a second ack.

The side effect: duplicates

Closing the channel returns every message that is still unacknowledged on it. We fetched three messages, acked the first two, then acked the first one again:

The consumer that reconnects gets it again. If the first copy is still being processed, or finishes and acks into a closed channel, the message is processed twice. With prefetch 50, it is up to 49 messages each time.

The fix