All ArticlesEmail2026-11-10T20:37:32+08:00

Postfix Queue Keeps Growing but mailq Shows All Deferred? Read the Logs for 4xx Clues

Your Postfix deferred queue keeps piling up and you don't know which remote servers are rejecting mail or why. After reading, you will know how to use qshape and mail.log to identify the blocking destinations and the specific 4xx errors causing the backlog.

You run mailq and every single message shows (deferred). Hundreds, maybe thousands of entries. Queue keeps growing, nothing leaves. The status column tells you that delivery failed temporarily, but not why or where. To fix this, you need two tools: qshape to find which destination domains are clogging the pipe, and your mail log to read the actual 4xx rejection messages those remote servers sent back.

What "Deferred" Actually Means

Postfix uses several internal queues. When a delivery attempt fails with a temporary error (any SMTP reply starting with 4), the message moves from the active queue into the deferred queue. Postfix retries deferred messages on an increasing backoff schedule. By default, messages stay in the deferred queue for around 5 days before Postfix gives up and bounces them.

So a growing deferred queue means: remote servers keep saying "not right now." The critical question is which servers and what reason. Without that, you are guessing.

Step 1: Use qshape to Find the Problem Domains

qshape reads the queue spool and groups messages by recipient domain and age. Run it against the deferred queue:

qshape deferred

Illustrative output format:

                         T  5 10 20 40 80 160 320 640 1280 1280+
                 TOTAL 1847  0  0  0  0  2   5  18  42   80  1700
      hotmail.com  923  0  0  0  0  1   3  10  20   39   850
        gmail.com  412  0  0  0  0  0   1   4  12   25   370
    example.co.id  310  0  0  0  0  1   1   2   5    8   293
       yahoo.com  202  0  0  0  0  0   0   2   5    8   187

The columns represent age buckets in minutes. Messages piled up in the 1280+ column have been stuck for over 21 hours. What matters here is the domain distribution. If one or two domains dominate, the problem is specific to those destinations. If every domain is affected equally, the problem is likely on your side (DNS resolution, blocked outbound port 25, disk/inode exhaustion, or your IP on a blocklist).

In the illustrative output above, hotmail.com holds half the queue. That narrows the investigation.

If qshape is not available on your system, it may need to be installed separately. On Debian/Ubuntu it typically comes with the postfix package or a postfix-utils package. On CentOS/RHEL, check for pflogsumm or postfix-perl-scripts depending on the version.

Step 2: Read the Logs for the Actual 4xx Errors

Now that you know which domains are stuck, search the mail log for delivery attempts to those domains. The log location depends on your distro:

  • Debian/Ubuntu: /var/log/mail.log
  • CentOS/RHEL: /var/log/maillog
  • Systems without rsyslog (like minimal Debian 12 installs): use journalctl -u postfix

If your server has no /var/log/mail.log at all, the article No /var/log/mail.log on Debian 12? Trace the Growing Postfix Queue With journalctl covers that specific situation.

Grep for the stuck domain and filter for status=deferred:

grep 'status=deferred' /var/log/mail.log | grep 'hotmail.com' | tail -20

Each deferred log line contains the remote server's response in parentheses. That response is the clue. Here are the patterns you will typically see and what they mean.

Step 3: Decode the Common 4xx Patterns

421 Too many connections / rate limited. Large providers like Gmail, Outlook, and Yahoo enforce connection and message-per-hour limits. If your server sends too many messages too fast, or if multiple domains on your server all send to the same provider simultaneously, you hit rate limits. The response usually includes language like "too many connections from your IP" or "try again later." The fix is not to flush the queue harder. Flushing (postqueue -f) retries everything at once and makes rate limiting worse. Instead, reduce Postfix's per-destination concurrency. The directive smtp_destination_concurrency_limit in main.cf controls how many simultaneous connections Postfix opens to a single destination. Lowering it to 2 or 3 for problem destinations often resolves this. For deeper coverage of this retry-vs-flush tradeoff, see Should You Run postqueue -f or Let Postfix Retry Deferred Mail on Its Own?.

450 4.7.1 Greylisting in effect. Some receiving servers intentionally reject the first delivery attempt from an unknown sender/IP pair and expect a retry a few minutes later. Postfix handles this automatically through its retry schedule. Greylisted messages look alarming in the queue but typically clear on the second or third attempt. If they do not clear after several hours, the greylisting server may have a longer delay window, or there is a second problem stacked on top.

421 4.7.0 ... listed on blocklist / poor reputation. Your server IP appears on a DNS-based blocklist (DNSBL). The remote server's response often names the specific list. Check your IP against common blocklists using tools like mxtoolbox.com or by querying the list directly with dig. Getting delisted is a manual process that varies per blocklist. Until you are delisted, mail to servers using that list will keep deferring.

451 4.7.1 Service unavailable / try again later. Generic temporary rejection. Could be the remote server is overloaded, undergoing maintenance, or applying content filtering that timed out. If this affects only one domain and clears within hours, it is usually the remote side's problem. If it persists, check whether your DNS (both forward and reverse) resolves correctly from the server.

450 4.1.8 Sender address rejected. The remote server does not like your envelope sender. This often happens when the sending domain lacks proper DNS records (no MX, no A record, or no reverse DNS on the sending IP). Verify with dig MX yourdomain.com and dig -x YOUR.SERVER.IP.

Connection timed out (not a 4xx, but defers the message). Postfix logs this as connect to mail.example.com[x.x.x.x]:25: Connection timed out. No SMTP response at all. Common causes: outbound port 25 blocked by your provider, firewall rules, or the remote server is genuinely down. Test with telnet mail.example.com 25 from your server. If you cannot connect to any remote mail server on port 25, your provider or firewall is blocking outbound SMTP.

Step 4: Narrow Down Whether the Problem Is You or Them

After reading the logs, you should have a specific error message. The next step depends on what you found:

If one or two domains dominate the queue and the error is rate limiting or greylisting: The queue will likely drain on its own. Lower your concurrency, wait, and monitor. Do not flush.

If the error mentions a blocklist: Check and request delisting. Meanwhile, legitimate mail to servers not using that blocklist should still flow. Confirm by checking qshape — if only certain domains are stuck, the rest of your mail is fine.

If every domain is stuck with connection timeouts: Check outbound port 25. Run telnet gmail-smtp-in.l.google.com 25 from the server. If it hangs, something between your server and the internet is blocking SMTP. Cloud providers sometimes block port 25 by default on new instances and require you to request an exception.

If the error references your sender domain or IP reputation: Verify your PTR record matches your HELO hostname, confirm SPF and DKIM are published and passing, and check that your server is not an open relay or sending spam from a compromised account. A compromised mailbox or web script generating spam is a common reason a queue fills with deferrals — the spam triggers rate limits and blocklists, which then defer your legitimate mail too. The article Finding a Compromised Mailbox in the Postfix Queue After Moving From cPanel Exim walks through identifying that scenario.

Step 5: Verify the Fix

After addressing the root cause, confirm the queue is draining:

  1. Run qshape deferred again after 15-30 minutes. The totals for the problem domain should start decreasing, and messages should appear in younger age buckets (meaning new retries are succeeding).
  2. Check mailq | grep -c '^[A-F0-9]' periodically to see the total queue count drop. On most systems, queue IDs start with hex characters, so this counts message entries.
  3. Grep the log for status=sent to the previously stuck domain: grep 'status=sent' /var/log/mail.log | grep 'hotmail.com' | tail -5. Seeing successful deliveries confirms the block is cleared.

If the queue is not draining and the error has changed, read the new error. Sometimes fixing one problem (like a blocklist) reveals a second one underneath (like missing DKIM).

The Diagnostic Habit Worth Building

A deferred queue is not an emergency by itself — it is Postfix doing exactly what it should: retrying. The emergency is not knowing why it is retrying. mailq alone does not tell you. qshape points you to the stuck domains, and the mail log gives you the remote server's exact words. Read those words. They almost always tell you what to fix. Building a habit of checking qshape deferred weekly, before users start complaining, catches these backlogs early — often before they become a real problem.