The Postfix mail queue holds messages that are waiting for delivery or have failed temporarily. You list it with postqueue -p (or mailq), flush it with postqueue -f, inspect a message with postcat -q, and remove messages with postsuper -d. Knowing these four commands lets you clear a stuck Postfix mail queue without losing legitimate mail.
This article assumes you can read the mail log. The log tells you why a message is stuck; the queue commands let you act on it.
Postfix keeps messages as files under /var/spool/postfix, grouped by state:
| Queue | Purpose |
|---|---|
incoming | Messages just received, not yet processed |
active | Messages the queue manager is currently trying to deliver |
deferred | Messages that failed temporarily and wait for a retry |
hold | Messages an administrator has frozen on purpose |
corrupt | Damaged files kept for inspection |
Most problems you troubleshoot are in the deferred queue. Postfix retries those messages automatically with increasing delays, between minimal_backoff_time (default 300 seconds) and maximal_backoff_time (default 4000 seconds), and gives up after maximal_queue_lifetime (default 5 days), when it returns the message to the sender as a bounce.
Example output:
An asterisk after the ID means the message is in the active queue. A ! means it is on hold. The line in parentheses is the last delivery error, so you often get the reason without opening the log.
To count how many messages wait, and to see which queue they are in:
postqueue -j prints one JSON object per message, which is handy for scripts. It has been available since Postfix 3.1.
Flushing asks Postfix to retry delivery now instead of waiting for the next scheduled attempt:
You can also retry one destination domain only:
Flushing does not fix the cause. If the remote server is down or your outbound port 25 is blocked, the messages return to the deferred queue with the same error. Fix the problem first (DNS, firewall, provider block, TLS policy), then flush. Flushing repeatedly while a remote server is rejecting you can make your reputation with that server worse.
To retry a single message, requeue it by ID:
postsuper -r ALL requeues everything, which re-runs address rewriting and is the right command after you change virtual_alias_maps or transport_maps.
Use postcat to read a queued message's envelope, headers and body:
Check the Received: headers, the sender and the recipient. A huge number of near-identical messages from one sender usually means a compromised account or a script gone wrong, which the open relay article deals with.
postsuper manages queue contents. Always give it explicit IDs unless you truly mean all.
postsuper -d ALL with no queue name deletes every message in every queue, including legitimate mail that is just waiting. There is no undo. Prefer deleting the deferred queue only, or delete by sender when you are cleaning up spam.
Postfix has no built-in filter option, so combine postqueue -j with jq:
The trailing - tells postsuper to read queue IDs from standard input. Run the jq part alone first to check the list it produces.
Symptom in postqueue -p | Likely cause |
|---|---|
Connection timed out to many hosts | Outbound port 25 blocked by a firewall or the hosting provider |
Host or domain name not found | Broken DNS resolver on your server |
refused to talk to me: 554 or 421 ... rate limited | The remote side limits or blocks your IP |
| Thousands of messages from one sender | Compromised account or application |
mail transport unavailable | A typo in transport_maps or a stopped service |
If the queue grows because of volume, not errors, tune concurrency per destination with default_destination_concurrency_limit and consider a smarthost relay.
When a message cannot be delivered, Postfix sends a bounce to the sender. If that bounce also fails, it goes to the address set by 2bounce_notice_recipient (default postmaster). A large queue of bounces to forged senders is a sign that backscatter is hitting you, so reject invalid recipients during the SMTP conversation instead of accepting and bouncing later.
It is safe for the server but it destroys mail that was not yet delivered. Delete only what you have identified as spam or junk, and keep the rest.
The queue manager retries a deferred message after a back-off that grows from 5 minutes towards about 67 minutes, until the 5-day limit. You can change this with minimal_backoff_time, maximal_backoff_time and maximal_queue_lifetime.
Nothing in practice. mailq is a compatibility command that calls postqueue -p.
No. Queue commands act on the running system. Only changes to main.cf need postfix reload.
List with postqueue -p, read details with postcat -q, retry with postqueue -f once the cause is fixed, and remove with postsuper -d using explicit IDs. Treat postsuper -d ALL as destructive, and use the error text next to each queued message to find the reason it is stuck.