How Postfix queues work, why they pile up, and the exact commands to drain, inspect, and recover them when things go sideways.
Postfix has four queues: incoming, active, deferred, hold. Most problems live in deferred.
mailq | tail -1 # total queue count
mailq | grep "^[A-F0-9]" | wc -l # just deferred count
postqueue -p | head -50 # first 50 entries with reasonsThe reason is always in the queue listing:
connect to gmail-smtp-in.l.google.com[...]:25: Connection refusedCommon causes:
Karanveer Singh Shaktawat
Full Stack Engineer & Infrastructure Architect
Building portfolio, contributing to open source, and seeking remote full-time roles with significant technical ownership.
Pick what you want to hear about — I'll only email when it's worth it.
Did this resonate?
How a bulk marketing campaign starved transactional email at Prachyam Studios — and how I fixed it by understanding Postfix queue internals and building a priority queue on top of Mailcow.
postqueue -f # retry all deferred messages now
postsuper -r ALL # requeue everything (forces re-evaluation)postqueue -f -d gmail.compostsuper -d ALL deferredWhen you're sending bulk mail and Gmail starts deferring you, don't flush aggressively. Rapid retries signal spam behavior and make the throttling worse. Postfix's default retry schedule (5min, 10min, 20min, ..., up to maximal_queue_lifetime) is deliberately conservative for a reason. Let it run.
Only flush manually when the underlying problem (wrong DNS, blocked port, bad SPF) is actually fixed — not before.
The full story of building a self-hosted email stack across 12 domains and 6 servers at Prachyam Studios — the architecture, the hard lessons, and why I'd do it again.