RabbitMQ - purge a queue from all of its unacked messages

I have thousands of unacked messages in my dev environment which I can't restart.
Is there a way to remove (purge) all messages even if they are unacknowledged?


Close the channel that the unacked messages reside on, which will nack them back into the queue, then call purge.


You have to make consumer ack them (or nack) and only after that they will be removed. Alternatively you can shutdown consumers and purge the queue completely.

If you are looking for some way to purge all unacked messages - there are no such feature nor in AMQP protocol neither in RabbitMQ.

It looks like your consumer is the cause of the problem, so you have to adjust it (rewrite) to release message immediately after it processed or failed.


Once there are no "ready" messages in the queue, delete it and recreate.


YOU WILL LOSE THE QUEUE CONTENTS with this method.

You need to put messages back into the queue before you can purge them:

  • close the channel
  • close the connection (the script doesn't work for me)

As an alternative, this doesn't require to wait:

  • delete and recreate the queue
  • restart the server