Mailgun

Mailgun: Unable to Connect to MX Servers

Why Mailgun logs "unable to connect to MX servers" — it can't open an SMTP session to the recipient's mail host. Causes, retry behavior, and how to fix it.

Updated Jul 1, 2026

The short answer

"Unable to connect to MX servers" is a Mailgun delivery-log message, not an SMTP reply code. Mailgun's outbound MTA looked up the recipient domain's MX records but could not open a TCP/SMTP session to any of them — the host did not answer, timed out, or refused the connection. It is usually a temporary (soft) failure: Mailgun automatically retries for up to 8 hours. Common causes are a recipient mail server that is down, firewalled, or a defunct/misconfigured recipient domain.

What does "unable to connect to MX servers" mean in Mailgun?

This is a Mailgun delivery-log message, not a standard 3-digit SMTP reply code. After Mailgun accepts your message ("accepted" event), its outbound MTA resolves the recipient domain's MX records (per RFC 5321 §5.1) and then tries to open a TCP/SMTP connection (typically on port 25) to each listed mail exchanger. This error means the MX hostnames were found, but Mailgun could not establish a working SMTP session with any of them — the connection timed out, was refused, or the host never answered.

It typically surfaces as a temporary failure event (an enhanced status in the 4.x.x class — "transient"), so the message is deferred and retried, not permanently bounced.

Distinguish it from "498 No MX for [domain]" — that error means no MX record exists at all (a DNS-level problem). "Unable to connect to MX servers" means the records exist but the connection to them fails.

What causes it?

  • Recipient mail server is down or unreachable — the listed MX host is offline, overloaded, or firewalled and silently drops/refuses connections on port 25. This is the most-cited cause in Mailgun support and community threads.
  • Defunct or misconfigured recipient domain — the MX points at a host that no longer exists or no longer accepts mail, so the address may no longer be valid.
  • Connection-level rate limiting or IP-based blocking — some receivers silently drop or refuse the TCP handshake itself (not an SMTP-level reply) when sending volume from an IP spikes, rather than issuing a clean 4xx reply.
  • Transient network/DNS issues between Mailgun and the destination.

Sending-IP volume/reputation can also cause this — many receivers throttle by silently refusing or dropping connections from an IP that has sent a high volume recently, rather than replying with an explicit 4xx/5xx. Don't rule out your own sending reputation just because you see a connection failure rather than a bounce reply. Content filtering, by contrast, typically produces a remote SMTP 4xx/5xx reply (e.g. a 421 throttle or 550 block), which Mailgun logs with the remote server's actual response text.

How do I fix it?

  1. Wait for Mailgun's automatic retries. Because this is a transient failure, Mailgun re-attempts delivery on an increasing schedule — roughly 10 min, 10 min, 15 min, 30 min, 1 hr, 2 hr, 4 hr, for up to 8 hours total (Mailgun: Will Mailgun retry my failed messages?). If the receiver was briefly down, a retry usually succeeds with no action from you.
  2. Verify the recipient domain's MX is actually reachable. Check its MX and try the connection yourself:
dig +short MX recipient-domain.com
nc -vz mx-host.recipient-domain.com 25 # or: openssl s_client -starttls smtp -connect host:25

If you also cannot connect, the problem is on the recipient's side, not Mailgun's or yours.

  1. Confirm the address is still valid. If the MX host is gone or never answers across many recipients, the destination may be defunct — remove or correct those addresses.
  2. If it expires, expect a permanent "Too old" failure. After the 8-hour retry window, Mailgun drops the message and records a permanent failure described as "Too old." Re-send only once the receiver is confirmed reachable.
  3. If it's widespread across many domains, suspect an outbound network/DNS issue and open a ticket with Mailgun support with the message ID and timestamps.

With Courier

Courier surfaces this as the provider (Mailgun) error on the message's delivery event. Use Courier's message logs to pull the affected recipients and the Mailgun message ID, then apply the checks above before re-sending.

FAQ

Common questions

No. A 421 is an SMTP reply the recipient server sends after a connection is established — it means the server answered but is throttling you. "Unable to connect to MX servers" means no SMTP session opened at all; the recipient's mail host did not respond, refused, or timed out. The fix is checking recipient-server reachability, not your IP reputation.

One API, every provider

Stop debugging raw provider errors

Courier connects to your email, SMS, and push providers, handles retries and failover, and surfaces delivery errors in plain language.

Reply-code definitions per RFC 5321 §5.1 (locating the target host / MX), RFC 3463. Last reviewed Jul 1, 2026. Courier is not affiliated with third-party providers; error behavior may vary by implementation.