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
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:
BASH
qshape deferredTEXT
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 1871280+ 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
- Debian/Ubuntu:
/var/log/mail.log - CentOS/RHEL:
/var/log/maillog - Systems without rsyslog (like minimal Debian 12 installs): use
journalctl -u postfix
/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:
BASH
grep 'status=deferred' /var/log/mail.log | grep 'hotmail.com' | tail -20Step 3: Decode the Common 4xx Patterns
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
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
- Run
qshape deferredagain 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). - 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. - Grep the log for
status=sentto the previously stuck domain:grep 'status=sent' /var/log/mail.log | grep 'hotmail.com' | tail -5. Seeing successful deliveries confirms the block is cleared.
The Diagnostic Habit Worth Building
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.