An SMTP conversation is a dialogue between two machines, and either side may hang up when the other takes too long or when something in between cuts the line. The result appears in logs and bounces as 421 4.4.2 Timeout waiting for client input, 421 4.4.2 Connection timed out, 4.4.1 Connection timed out, lost connection with remote host while sending end of data or simply a client-side message about a read timeout. These are temporary failures, so a well-behaved sender queues the message and retries. When they persist, they point to a problem in the path: a slow or failing DNS lookup, a firewall that drops packets, a mismatch in packet size, an overloaded receiver, a message too big for the timeouts in force or a client that sits idle too long. This guide explains the different stages where timeouts occur, how to tell them apart from the log and the reply, how to test each hypothesis with simple commands and what to change on the sending and receiving sides.
Stages where a timeout can occur
| Stage | What is happening | Typical symptom |
|---|---|---|
| TCP connect | Client opens a connection to port 25, 465 or 587 | Connection timed out; no greeting at all |
| Greeting banner | Server sends 220 after accepting the connection | Delay before 220; some servers pause deliberately or perform lookups first |
| EHLO and STARTTLS | Capabilities exchange and TLS handshake | Hang after STARTTLS; handshake never completes |
| Authentication | Client sends credentials | Delay while the server consults a slow directory |
| MAIL FROM / RCPT TO | Addresses are checked by the server | Delay while the server does DNS or policy lookups |
| DATA transfer | Client sends the message body | Timeout mid-transfer, often for large messages or slow links |
| After the final dot | Server processes the message and replies 250 | Timeout waiting for the response; message may or may not be accepted |
| Idle between messages | Pooled connection sits unused | 421 4.4.2 Timeout waiting for client input |
The distinction matters. A timeout before the greeting points to the network or the server being down. A pause after RCPT TO suggests the receiver is performing slow lookups on you. A timeout after the final dot is the most delicate, because the server may have accepted the message but the client never saw the 250; a blind retry then sends a duplicate. See SMTP connection pooling for idle handling and reliable sending queues for idempotency.
Diagnosing from the client
# 1. Can we reach the port at all? (time the stages)
time nc -vz mail.example.net 25
# 2. See the greeting and EHLO response (plain text)
openssl s_client -starttls smtp -connect mail.example.net:25 -crlf -servername mail.example.net
# 3. Trace the path to find where packets stop
mtr -rwz -c 20 mail.example.net
# 4. Test packet size problems: try a do-not-fragment ping of typical size
ping -M do -s 1472 mail.example.netIf step 1 fails or hangs, the connection is blocked or the host is down; check outbound firewall rules, your provider's policy on port 25 and the server's status. See why port 25 is blocked. If the greeting arrives slowly, the server is busy or performs lookups before replying. If the session dies right after STARTTLS, suspect a TLS problem: see SMTP timeouts and TLS errors and certificate errors. If the large DATA transfers fail while small messages succeed, suspect MTU or size limits.
MTU and fragmentation
A classic cause of sessions that start fine and then hang is a path MTU problem. Small commands fit in one packet; the message body fills larger packets, which a router or tunnel along the path cannot carry, and if ICMP "fragmentation needed" messages are blocked by a firewall, the sender never learns to use smaller packets. The connection hangs during DATA until a timeout. VPNs, tunnels and some cloud networks reduce the MTU below 1500. The fix is to allow the relevant ICMP messages, or to lower the MTU or enable MSS clamping on the gateway. The ping test above, with decreasing sizes, shows the largest packet that passes.
Slow DNS and reverse lookups
Receiving servers often look up your IP's reverse DNS, your HELO name and blocklists while the session is open. If their resolvers are slow, or if your reverse DNS name servers are unresponsive, the server waits and may time out. Similarly, your own server needs MX and A lookups before it can connect, and a slow resolver makes every delivery slow. Check that your DNS servers respond quickly and that the PTR record for your IP exists and its name servers answer. See reverse DNS and Gmail 550 5.7.25. On the receiving side, set sensible DNS timeouts for blocklist lookups so that a failing list does not stall your own server.
Idle timeouts and pooled connections
Servers close sessions that sit idle, typically after a few minutes, and they say so with 421 4.4.2 Timeout waiting for client input. Applications that keep a connection open between bursts of mail will see this error on the next send. The remedy is to detect the closed connection, reconnect and retry that message, to send a NOOP command now and then to keep the session alive or to close sessions when idle. Mind that the client must treat the 421 as the end of the session: after a 421 reply the server closes the connection, and further commands will fail.
Large messages and slow links
A message with big attachments takes time to transfer and to scan. Both sides have timeouts for the DATA phase and for the response after the final dot, which may be long (the standard recommends ten minutes for the final reply) but is shorter on some configurations. If large messages fail while small ones succeed, reduce the size, link to files instead, or ask the administrator to raise the timeouts. See size limits and attachments and spam filters. On the sending side, make sure your own queue does not have a short per-connection timeout that cuts transfers on slow links.
Overloaded or throttling receivers
When a receiver is under heavy load, or when it deliberately slows connections from senders it distrusts (a tactic called tarpitting), the symptoms are slow responses and timeouts. They often come with 4xx replies about rate or reputation. Reduce your connection count, lower your rate to that domain and check your reputation and blocklist status with the blacklist check. See email throttling and 421 try again later.
Settings to review
| Side | Setting | Notes |
|---|---|---|
| Sender (Postfix) | smtp_connect_timeout, smtp_helo_timeout, smtp_data_done_timeout | Defaults are generous; raise only with evidence |
| Sender (application) | Library socket timeout, for example 30 seconds | Too short breaks slow servers; too long ties up workers |
| Receiver (Postfix) | smtpd_timeout, smtpd_starttls_timeout | Idle and TLS handshake limits |
| Firewall | Connection tracking timeouts | Idle connections may be dropped silently by a stateful firewall or NAT |
| Load balancer | Idle timeout on TCP listeners | Must exceed the longest expected pause |
| Resolver | Timeout and retry counts | Slow resolvers multiply every delay |
A stateful firewall or NAT gateway that discards idle connections without sending a reset causes particularly confusing symptoms: the client believes the session is open, sends data and waits forever. Enabling TCP keep-alives on the client with an interval shorter than the firewall timeout prevents this.
What the sender should do with the retry
- Treat the failure as temporary and keep the message queued.
- Retry with increasing delays, from the same IP.
- If the failure happened after the final dot, check your logs or the recipient before assuming that the message was not delivered. Use unique Message-IDs so that duplicates can be recognised. See Message-ID header.
- Give up after the maximum queue time and report the last error.
- Alert on a rising share of timeouts; it is often the first sign of a path problem.
Timeouts look mysterious until you divide the session into stages and time each one. Test the connection, the greeting, the TLS handshake and a small and a large message in turn, and the stage at which the delay or break appears usually names the cause.
Skip the network plumbing Send through a relay with maintained connectivity and clear delivery logs.
References and further reading
Frequently asked questions
What does 421 4.4.2 mean?
The server closed the connection, often because the client was idle too long or the session timed out. It is temporary, so reconnect and retry.
Why do small emails work but large ones time out?
Large messages take longer to transfer and scan, and path MTU problems or short timeouts show up only with big packets.
Why does the connection hang after STARTTLS?
A TLS problem, a firewall that mishandles the handshake or an MTU issue. Test with openssl s_client.
Can a timeout cause duplicate emails?
Yes, if the server accepted the message but the client did not see the 250 reply and retried. Use unique message IDs and idempotent queues.
How do I keep pooled SMTP connections from timing out?
Send NOOP periodically, close idle connections or reconnect on 421 and retry the message.