About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
After a server moves to a new network, mail that the application used to send can start to sit in the queue. If the delivery attempts never get a reply, the new network may be blocking outbound TCP port 25. That is a provider or firewall policy, not a fault in the application or its DNS records.
Prove it by testing TCP port 25 from the moved server and comparing it with port 587 to an authenticated relay. The usual fix is to send through that relay. The alternative is to ask the provider to lift the block, which some providers allow and some do not.
This article is about a connection that never completes. If the remote server answers and refuses the mail, because of SPF, DKIM, DMARC or a reverse DNS record, that is a different fault.
What the error means
Direct SMTP delivery connects from your server to the recipient's mail server on TCP port 25. Several large platforms stop that traffic by default.
- Azure. Microsoft states that "The Azure platform blocks outbound SMTP connections on TCP port 25 for deployed VMs." The Azure guidance (updated 2026-03-27) says the block depends on subscription type. In standard Enterprise Agreement and Microsoft Customer Agreement for enterprise (MCA-E) subscriptions, port 25 is not blocked. For Enterprise Dev/Test subscriptions it is blocked by default, though the block can be removed. For all other subscription types it is blocked. A change of subscription type "might result in outbound SMTP being blocked."
- AWS. The EC2 guide says EC2 "allows outbound traffic over port 25 only to private IPv4 addresses" by default, and traffic to public IPv4 and IPv6 addresses is blocked. Destinations inside the VPC's primary CIDR block and RFC 1918 and RFC 6598 ranges are not affected.
- Google Cloud. Google's email guide (updated 2026-11-10) says connections to TCP port 25 are blocked when the destination is outside your VPC network, "However, some projects do not have this restriction." Ports 587 and 465 to external destinations are not restricted.
Your own firewall can do the same thing. A moved server behind a new egress rule set with port 25 left out behaves identically from the application's point of view.
Postfix, used as the example mail server here, gives up on a connection after smtp_connect_timeout, which the Postfix parameter reference lists as 30 seconds by default, then "tries the next address on the mail exchanger list". If every address times out, the message stays in the queue and is retried later. postqueue -p shows the queue and, for mail that could not be delivered at the last attempt, the reason for failure.
Likely causes
| Cause | What you see | How to confirm |
|---|---|---|
| Provider blocks outbound port 25 by default | Every external recipient times out; internal relays work | TCP test to port 25 fails, to port 587 on a relay succeeds |
| Subscription or account type does not allow port 25 | Worked in one subscription, fails in another (Azure) | Check the subscription type against Microsoft's list |
| Block applies to public destinations only (AWS) | Mail to an internal relay works, external does not | Test to a private address against a public one |
| New egress firewall rule omits port 25 | A host in the same subnet with the same policy fails too | Compare with another host; packet capture shows SYNs with no reply |
| Relay port is not open either | Port 587 or 465 also times out | Test port 587 and 465 to the relay |
Prove the cause before changing anything
These commands are taken from vendor documentation and have not been run or lab-tested. None of them changes the server.
1. Read the queue.
postqueue -p
You should see queued messages, each with a reason for the last failure. The Postfix FAQ shows the log shape for a deferral: status=deferred ( followed by a reason in brackets, such as a DNS failure. Postfix's documentation does not give the exact reason text for a connect timeout, so read the mail log for the delivery attempts of one queue ID and look for a connect or timeout reason rather than a reply from the remote server. A reason that quotes a reply from the remote server (an SMTP reply code and text) means the connection worked and the remote side refused the mail, which is the other fault.
2. Find a real mail server to test against. Use a recipient domain that the application sends to.
Resolve-DnsName -Name example.com -Type MX
Resolve-DnsName with -Type is documented on Microsoft Learn. Pick the lowest-preference mail server.
3. Test TCP port 25 from the moved server. On Windows, Test-NetConnection takes -ComputerName, -Port and -InformationLevel, and its Detailed output includes TcpTestSucceeded.
Test-NetConnection -ComputerName mx1.example.com -Port 25 -InformationLevel Detailed
Bad result: TcpTestSucceeded is False. Good result: TcpTestSucceeded : True, shown in Microsoft's sample for port 80.
On Linux, the OpenSSL s_client page documents an SMTP test of this shape:
openssl s_client -brief -starttls smtp -connect mx1.example.com:25
The page does not print sample output. Expect a good run to report a connection and a TLS session. A blocked port should instead stall and end with a connection error, with no session at all.
4. Run the control test. Repeat step 3 against your relay on port 587. Microsoft says authenticated relay services on port 587 are not blocked in Azure, and Google says ports 587 and 465 to external destinations are not restricted. If port 587 works and port 25 does not, you have shown a policy on port 25.
5. Optional capture. The Postfix debugging guide records a session with tcpdump -w /file/name -s 0 host example.com and port 25. A block shows as connection attempts leaving with no answer from the far end. If a capture on the server shows the attempts leaving and nothing returning, the drop is on the path, not in Postfix.
6. Rule out your own firewall. Test from a second host in the same subnet that has an exception, or read the egress rules for the subnet. A change here is a firewall rule change, so treat it as a controlled change.
Fix
Preferred: send through an authenticated relay on port 587 or 465. Microsoft recommends authenticated SMTP relay services and says port 587 is not restricted in Azure. In Postfix, the small-office guide shows the pattern:
relayhost = [mail.isp.example]:submission
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = lmdb:/etc/postfix/sasl_passwd
smtp_tls_security_level = encrypt
smtp_sasl_tls_security_options = noanonymous
The [ and ] stop MX lookups, and :submission means TCP port 587. In /etc/postfix/sasl_passwd the destination must be written in the same form, for example [mail.isp.example]:submission username:password. Keep that file readable only by root, then run postmap /etc/postfix/sasl_passwd after each change. For port 465 the guide says the wrapper-mode setting smtp_tls_wrappermode = yes is used (Postfix 3.0 and later). Use your own relay's host name and credentials.
Disruptive step: changing relayhost redirects all outbound mail from this server to the relay. Reload Postfix with postfix reload, send a test message first, and keep the previous main.cf so you can back out. The relay's own rules, rate limits and sender checks apply, and your SPF record may need the relay's sending addresses.
Alternative: ask the provider to lift the block.
- Azure: for Enterprise Dev/Test subscriptions, run the diagnostic in the "Cannot send email (SMTP-Port 25)" section of Diagnose and Solve on the Virtual Network resource. After the exemption the VMs must be stopped, deallocated and restarted to pick up the new policy. Microsoft says the exemption applies only to that subscription and only to traffic routed directly to the internet. For other subscription types, Microsoft points to an authenticated relay instead.
- AWS: AWS re:Post says you must submit a request. If instances are in more than one Region, submit a separate request for each. The request asks for a use case and how you will stop unwanted outbound mail, can take up to 48 hours, and can be refused; the re:Post page says to rewrite the use case and submit again.
- Google Cloud: the guide says some projects are not restricted; otherwise use ports 587 or 465 with a relay.
Even where port 25 is open, Microsoft notes there is no guarantee that external domains accept the mail.
After the path works, flush the queue. postqueue -f attempts delivery of all queued mail. Risk: old messages will be sent at once, so check the queue first with postqueue -p and clear anything you do not want delivered.
Confirm the fix
- Repeat the TCP test from step 3 against the relay's port.
TcpTestSucceededshould be True. - Send one test message and find its queue ID in the mail log. You want a delivery to the relay, not a deferral.
- Run
postqueue -pand confirm the queue is draining and the reason column no longer shows a connection failure. - Ask a recipient to confirm one message arrived.
What to watch afterwards
- The size of the queue. A growing queue means the path has broken again.
- Subscription changes. Microsoft warns that moving from an Enterprise Agreement to another type can bring the block back.
- Relay rate limits and sending reputation, which are the relay's rules and not yours.
- Any other server in the same move that sends mail directly: scheduled reports, monitoring, ticketing and MFA codes.
Example (illustrative): app02 is moved from an office network to a cloud VM. Invoice emails queue. postqueue -p lists them with a failed-connection reason. From app02, Test-NetConnection -ComputerName mx1.example.com -Port 25 -InformationLevel Detailed reports TcpTestSucceeded : False, while the same test to smtp.relay.example on port 587 returns True. The administrator sets relayhost = [smtp.relay.example]:submission with credentials, reloads Postfix and flushes the queue after checking it. The invoices are delivered.
Read next
Related articles you may want next.
- HostingApplication Email Rejected or Junked After a Server Move: SPF, DKIM, DMARC and PTRApplication mail bouncing or junked after a migration? Read Authentication-Results, then fix SPF, DKIM, DMARC alignment, PTR and Microsoft 365 relay settings for the new path.Read article
- HostingOutbound email as a hidden dependency of hosted business applicationsWhat breaks in hosted LOB workflows when SMTP relay, authentication or sender policy fails—even when interactive login still works.Read article
- HostingKeeping email notifications and MFA working when the application server movesKeep email notifications and staff sign-in working through a hosting move. Check mail relays, registered application addresses and authentication dependencies with controlled tests.Read article
Risks and limits
- Postfix's documentation does not print the exact log line for a connection timeout. Use the queue reason and the TCP test as the proof.
- Provider policies change and depend on account type and Region. Read the current provider page before you rely on any of them.
- The Postfix settings shown are for a Postfix mail server using a relay with SASL login; other mail software uses different settings.
- A relay does not cure reputation or authentication problems at the recipient. That is the separate fault of SPF, DKIM and reverse DNS rejection.
Sources
- Troubleshoot outbound SMTP connectivity problems in Azure — Microsoft Learn, last updated 2026-03-27, accessed 17 November 2026
- Amazon EC2 service quotas: Restriction on email sent using port 25 — Amazon Web Services, date not shown, accessed 17 November 2026
- Remove port 25 restrictions for instances and functions — AWS re:Post, date not shown, accessed 17 November 2026
- Sending email from an instance — Google Cloud, last updated 2026-11-10, accessed 17 November 2026
- postqueue(1) — Postfix, date not shown, accessed 17 November 2026
- Postfix configuration parameters — Postfix, date not shown, accessed 17 November 2026
- Postfix Small/Home Office Hints and Tips — Postfix, date not shown, accessed 17 November 2026
- Debugging Postfix — Postfix, date not shown, accessed 17 November 2026
- Postfix FAQ — Postfix, date not shown, accessed 17 November 2026
- Test-NetConnection — Microsoft Learn, date not shown, accessed 17 November 2026
- Resolve-DnsName — Microsoft Learn, date not shown, accessed 17 November 2026
- openssl-s_client — OpenSSL project, date not shown, accessed 17 November 2026
This article was originally published on .