Skip to content

MX Priority Explained

Short answer

The number in front of an MX record is a preference value: lower is tried first. A sending server sorts your MX records by that number, attempts the lowest, and only moves to a higher one if the lower host is unreachable. Equal numbers are tried in random order to spread load.

Check it yourself
MX Lookup
Mail servers and priorities for a domain

An MX record has two parts: a 16-bit preference value and the hostname of a mail server. The preference is not a weight, a percentage, or a quality score — it is purely an ordering. RFC 5321 defines the behaviour precisely: a sender collects all MX records for the domain, sorts them by preference ascending, and tries them in that order, falling through to the next only when delivery to the current one fails at the connection level.

dig +short gmail.com MX

# 5   gmail-smtp-in.l.google.com.
# 10  alt1.gmail-smtp-in.l.google.com.
# 20  alt2.gmail-smtp-in.l.google.com.
# 30  alt3.gmail-smtp-in.l.google.com.
# 40  alt4.gmail-smtp-in.l.google.com.
dig +short does not sort. Read the numbers, not the line order.

That last point catches people out constantly. dig +short prints records in whatever order the nameserver returned them, which is frequently shuffled. The record listed first is not the one that gets tried first — the record with the *lowest number* is. Use the MX Lookup if you want them presented in the order a sending server would actually use them.

MX Lookup
Mail servers and priorities for a domain

How does a sending server actually choose?

  1. Look up MX records for the recipient domain.
  2. If there are none, fall back to the domain's A or AAAA record and deliver there — the "implicit MX" rule. This is why mail sometimes lands on a web server that was never meant to receive it.
  3. Sort the MX records by preference, lowest first. Group records that share a preference value.
  4. Within each group, try the hosts in random order so load spreads evenly across equal-preference servers.
  5. Connect to the first host. If the connection fails — refused, timed out, no route, or the TLS handshake collapses — move to the next host in the list.
  6. If a host *accepts* the connection and then rejects the message with a permanent error (5xx), stop. The message bounces. Higher-preference records are not tried, because the domain's mail system has given an answer.
  7. If a host answers with a temporary error (4xx), the sender queues the message and retries later, typically starting the whole MX selection over on the next attempt.
Step 6 is the one that surprises people: failover happens at the connection level, not the message level. A backup MX only ever sees traffic when the primary is unreachable — not when it rejects a message.

How do you read the numbers?

The values are unsigned 16-bit integers — 0 through 65535 — and only their relative order carries meaning. 1, 2, 3 behaves exactly like 10, 20, 30, which behaves exactly like 5, 500, 5000. The convention of stepping in tens exists only so you can insert a server between two existing ones later without renumbering everything.

ConfigurationBehaviour
10 mail.example.com.Single mail server. Everything goes here; no failover exists.
10 primary. / 20 backup.Backup receives mail only while the primary is unreachable.
10 a. / 10 b. / 10 c.Equal preference: senders pick randomly, distributing load across all three.
10 a. / 10 b. / 50 backup.Load spread across a and b; backup used only when both are down.
0 .Null MX (RFC 7505) — this domain accepts no mail at all. example.com publishes exactly this.
1 smtp.provider. (one record)The pattern most hosted-mail providers now use; their anycast fleet handles redundancy behind one name.

The single-record pattern is worth noting because it looks wrong to anyone trained on the 10/20/30 convention. A provider running a global anycast mail fleet does its own failover inside one hostname, so a second MX would add nothing. google.com itself publishes one record, 10 smtp.google.com.; Microsoft 365 tenants publish a single 10 <tenant>.mail.protection.outlook.com.. Check your provider's current documentation for the exact hostname before publishing, and verify with the MX Lookup afterwards.

The backup MX that makes things worse

The classic mistake is adding a second MX at a higher number "for redundancy" without configuring that host to relay for your domain. It fails in one of two ways, and both are worse than having no backup at all.

  • The backup rejects the mail. It has no idea it is supposed to accept @example.com, so it answers 550 relay not permitted. Because that is a permanent rejection from a host that accepted the connection, the sender bounces the message immediately. Without the backup record, the sender would simply have queued and retried until the primary came back.
  • The backup accepts the mail and cannot deliver it. It queues messages for a destination it has no route to. They sit until the queue lifetime expires — often days — and then bounce, long after the primary recovered. Meanwhile the sender was told delivery succeeded.
  • The backup becomes a spam target. Sending directly to the highest-numbered MX is an old spammer habit, on the assumption that backup hosts run weaker filtering. If your backup does not apply the same filtering and recipient verification as the primary, it becomes the soft way in.
  • Backscatter. A backup that accepts mail for nonexistent recipients and only discovers this when relaying will generate bounces to forged senders, which is a fast route onto blocklists. Check yours with the Email Blacklist Check.

A backup MX is only worth having if it genuinely stores and forwards for your domain, knows your valid recipients, and filters as aggressively as the primary. If it does not, remove it — sending servers already retry for days on their own, which is exactly the resilience a backup was meant to provide.

Rules that make an MX record invalid

  • The target must not be a CNAME. RFC 2181 section 10.3 requires the MX exchange field to name a host with address records. Pointing MX at an alias produces inconsistent behaviour across senders — some deliver, some refuse. See CNAME vs A Record.
  • The target must not be an IP address. MX 10 203.0.113.10 is malformed. Create a hostname with an A record and point the MX at that.
  • The target must resolve. An MX pointing at a hostname with no address record is a dead end; senders will fall through or bounce.
  • Duplicate preferences are legal, duplicate records are not useful. Two identical MX records for the same host at the same preference are redundant, not doubled capacity.
  • A null MX must stand alone. MX 0 . declares the domain accepts no mail and must be the only MX record present.
# Verify each MX target is a real host, not an alias
for h in $(dig +short example.com MX | awk '{print $2}'); do
  echo "== $h"
  dig +short "$h" A
  dig +short "$h" CNAME    # any output here means the MX is invalid
done
If the CNAME query returns anything, fix the MX target before you do anything else.

Priority is not deliverability

MX records govern mail coming *in*. They have no effect on whether your outbound mail is accepted, which is decided by SPF, DKIM, DMARC, and your sending IP's reputation. The major mailbox providers expect bulk senders to publish SPF and DKIM with DMARC alignment, to have valid reverse DNS on the sending IP, to offer one-click unsubscribe on bulk mail, and to keep spam complaint rates low. None of that is influenced by an MX preference number.

Check the outbound side separately: SPF Checker, DKIM Checker, DMARC Checker, and Reverse DNS Lookup for the PTR record. The Email Deliverability Test runs all of them at once. If your mail broke immediately after a DNS change rather than gradually, start with Mail Bouncing After a DNS Change?.

Email Deliverability Test
SPF + DKIM + DMARC + MX + PTR on one screen

When you do change MX records, treat the cutover carefully. Sending servers cache MX answers for the record TTL, and a queued message may not retry for hours — so keep the old mail host accepting and forwarding for days after the switch. The lead-in procedure is in Lower Your TTL Before a DNS Migration.

Frequently asked questions

Does a lower priority number mean a better server?
It means a more preferred one, nothing else. The number expresses ordering only — there is no notion of capacity, quality, or weighting in an MX record. If you want to split load across servers, give them the same preference value; senders will choose randomly among equals.
What happens if my primary MX rejects a message with a 5xx error?
The message bounces immediately and the backup MX is never tried. Failover only happens when a host cannot be connected to at all. This is why a backup MX does not protect you from a misconfigured primary that is up but rejecting valid mail — only from one that is genuinely unreachable.
Can I use MX priority to split mail between two providers?
Not reliably. Equal preferences distribute connections randomly, so each provider receives an unpredictable share of mail and neither has the full mailbox. Split delivery is a routing decision made inside one mail platform, not something DNS can express. Use a single MX destination and configure forwarding or dual delivery there.
My domain has no MX record. Where does mail go?
To the domain's A or AAAA record, under the implicit MX rule — usually your web server, which is almost certainly not running a mail service, so mail bounces or vanishes. If the domain should never receive mail, publish a null MX (MX 0 .) instead, which tells senders to reject immediately rather than trying. Confirm what you have with the MX Lookup.
Why do my MX records come back in a different order each time?
Many nameservers rotate the order of records in a response set to spread load. The order in the answer is meaningless for MX; only the preference numbers determine sequence. Any sender implementing RFC 5321 sorts them itself before attempting delivery.
How long should the TTL on MX records be?
3600 seconds is a reasonable steady state, and some operators go higher for stability. Lower it to 300 a day or two before a mail migration so the cutover is quick, then raise it again once mail is confirmed flowing. Remember that sending servers cache MX answers too, so keep the old host receiving for several days regardless of the TTL.

Last updated: 2026-09-01