You changed mail providers, a customer says your mail bounces, or you just want to know where acme.com keeps its email. Any of these needs the same answer: the domain's MX records. You can read them in seconds, from a browser or a terminal, and the answer tells you more than most people get out of it.
TL;DR
- Quickest: type the domain into our free MX lookup. It shows every record, priority, TTL, the mail provider, server IPs and reverse DNS, and flags null MX and missing records.
- Terminal:
dig MX example.com +short(macOS, Linux),nslookup -type=mx example.com(Windows),Resolve-DnsName example.com -Type MX(PowerShell). - Read it right: sort by the number, lowest first (RFC 5321, section 5.1).
0 .is a null MX: the domain takes no mail. "No answer" means no MX at all; NXDOMAIN means the domain doesn't exist.
Check MX records in five steps
- Look up the MX records. Run dig MX example.com (macOS, Linux), nslookup -type=mx example.com (Windows) or Resolve-DnsName example.com -Type MX (PowerShell), or use the Mail Exchange MX lookup in your browser.
- Sort the answers by priority. Resolvers return MX records in any order. Sort them by the preference number: the lowest number is tried first and equal numbers share the load.
- Check that each mail server resolves. Look up the A and AAAA records of every host name in the answer. Each one must return at least one address; a host that doesn't resolve can't receive mail.
- Read the response status. NOERROR with records is normal. A single record of 0 . is a null MX (no mail accepted). NOERROR with no answer means there is no MX record. NXDOMAIN means the domain doesn't exist.
- Compare resolvers and the authoritative server. After a change, query 1.1.1.1, 8.8.8.8 and the domain's own name server. If they disagree, cached answers are still within their TTL.
The fastest way: our MX lookup
The Mail Exchange MX lookup runs in your browser against public DNS (Cloudflare and Google), so the domain you type never reaches our servers. For each record it shows the priority, the host name, the TTL, the mail provider recognised from the host name, the server's IPv4 and IPv6 addresses and their reverse DNS. It also flags the problems people miss in raw output: a null MX, no MX at all, an MX that points to a CNAME or an IP address, a mail host that doesn't resolve, and Cloudflare and Google giving different answers.
If you also want to see whether the domain can send properly, the email authentication checker reads MX, SPF, DKIM and DMARC for up to 25 domains at once.
The rest of this page covers the command-line tools, which are what you'll reach for on a server, in a script, or when you need to ask one particular DNS server.
Check MX records with dig (macOS, Linux)
dig ships with macOS and most Linux distributions (on Debian and Ubuntu it's in the bind9-dnsutils or dnsutils package). Here is the full answer for our own domain, run on 24 November 2026:
$ dig MX mailexchange.com
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 10529
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 1
;; QUESTION SECTION:
;mailexchange.com. IN MX
;; ANSWER SECTION:
mailexchange.com. 300 IN MX 1 aspmx.l.google.com.
mailexchange.com. 300 IN MX 10 alt4.aspmx.l.google.com.
mailexchange.com. 300 IN MX 5 alt2.aspmx.l.google.com.
mailexchange.com. 300 IN MX 5 alt1.aspmx.l.google.com.
mailexchange.com. 300 IN MX 10 alt3.aspmx.l.google.com.
;; Query time: 22 msec
;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP)
What to read, top to bottom:
status: NOERROR: the domain exists and the server answered.ANSWER: 5says five records came back.- The flags:
rd rameans we asked for, and got, a recursive lookup through a resolver. There's noaa(authoritative answer) flag, so this came from a cache. - Each answer line: name, TTL in seconds (300 = 5 minutes), class
IN, typeMX, then the preference and the exchange (the mail server's host name). The trailing dot on the host name is normal: it marks a complete name. - The order is random. The resolver returned 1, 10, 5, 5, 10. Sorted, this is the classic Google Workspace set: 1, then two at 5, then two at 10. Senders try 1 first and pick at random between records that share a number, which RFC 5321 requires ("MUST randomize them to spread the load").
SERVER: which resolver answered. Here it's the local stub resolver on 127.0.0.53, which forwards to the machine's configured DNS.
Useful variations:
# just the records
$ dig MX mailexchange.com +short
10 alt3.aspmx.l.google.com.
5 alt2.aspmx.l.google.com.
1 aspmx.l.google.com.
10 alt4.aspmx.l.google.com.
5 alt1.aspmx.l.google.com.
# sorted by priority
$ dig MX mailexchange.com +short | sort -n
# ask a specific resolver
$ dig @1.1.1.1 MX mailexchange.com +short
$ dig @8.8.8.8 MX mailexchange.com +noall +answer
# ask the domain's own name server (no cache)
$ dig NS mailexchange.com +short
kanye.ns.cloudflare.com.
celine.ns.cloudflare.com.
$ dig @kanye.ns.cloudflare.com MX mailexchange.com +norec
;; flags: qr aa; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 1
The last answer carries the aa flag: it came straight from the zone's authoritative server, so it shows what is published right now, with the full TTL. When you've just changed records, this is the answer to trust; the resolvers catch up once their cached copy expires.
dig MX mailexchange.com, 24 November 2026. The trailing dot marks a complete host name. Records come back in random order; sort them by preference.nslookup (Windows, macOS, Linux)
nslookup is on every Windows machine and most others. The same domain:
$ nslookup -type=mx mailexchange.com
Server: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
mailexchange.com mail exchanger = 10 alt4.aspmx.l.google.com.
mailexchange.com mail exchanger = 5 alt2.aspmx.l.google.com.
mailexchange.com mail exchanger = 5 alt1.aspmx.l.google.com.
mailexchange.com mail exchanger = 1 aspmx.l.google.com.
mailexchange.com mail exchanger = 10 alt3.aspmx.l.google.com.
"Non-authoritative answer" just means it came from a resolver's cache, which is normal. Windows' own nslookup prints the same data in a slightly different layout, with MX preference = 1, mail exchanger = aspmx.l.google.com on each line. To ask a particular server, add it at the end: nslookup -type=mx mailexchange.com 1.1.1.1.
nslookup is also the clearest about the two "nothing here" cases, which look alike in other tools:
$ nslookup -type=mx thisdomaindoesnotexist-mx-test-8812.com 1.1.1.1
** server can't find thisdomaindoesnotexist-mx-test-8812.com: NXDOMAIN
$ nslookup -type=mx www.mailexchange.com 1.1.1.1
*** Can't find www.mailexchange.com: No answer
Authoritative answers can be found from:
mailexchange.com
origin = celine.ns.cloudflare.com
mail addr = dns.cloudflare.com
...
minimum = 1800
NXDOMAIN: the name doesn't exist at all. "No answer": the name exists (www.mailexchange.com has a web address) but has no MX record. The SOA record printed underneath is there so resolvers know how long they may cache that negative answer: the lower of the SOA's own TTL and its minimum field (RFC 2308, section 3), here 1,800 seconds.
PowerShell: Resolve-DnsName
On Windows, PowerShell's DnsClient module has Resolve-DnsName, which returns objects you can sort and filter instead of text to parse:
PS> Resolve-DnsName mailexchange.com -Type MX
PS> Resolve-DnsName mailexchange.com -Type MX -Server 1.1.1.1 -DnsOnly |
Sort-Object Preference | Select-Object Preference, NameExchange, TTL
Each MX record comes back with NameExchange (the mail host) and Preference properties. -Server picks the resolver, -DnsOnly skips the LLMNR and NetBIOS fallbacks, and -NoHostsFile ignores the local hosts file (Microsoft's Resolve-DnsName reference, checked 2026-11-24). The cmdlet is Windows-only; PowerShell on macOS and Linux doesn't include it.
host (macOS, Linux)
host comes with the same package as dig and gives the shortest readable answer:
$ host -t mx mailexchange.com
mailexchange.com mail is handled by 10 alt3.aspmx.l.google.com.
mailexchange.com mail is handled by 5 alt2.aspmx.l.google.com.
mailexchange.com mail is handled by 1 aspmx.l.google.com.
mailexchange.com mail is handled by 10 alt4.aspmx.l.google.com.
mailexchange.com mail is handled by 5 alt1.aspmx.l.google.com.
$ host -t mx example.com
example.com mail is handled by 0 .
$ host -t mx thisdomaindoesnotexist-mx-test-8812.com
Host thisdomaindoesnotexist-mx-test-8812.com not found: 3(NXDOMAIN)
The middle one is a null MX: a single record with preference 0 and the host .. RFC 7505 (June 2015) defines it as the way a domain says it accepts no email, and a domain that publishes it "MUST NOT advertise any other MX RR". example.com is reserved for documentation, so it publishes one. Our page on null MX covers when to use it.
DNS over HTTPS with curl
When you can't install dig, or port 53 is blocked (some corporate and hotel networks do this), ask a public resolver over HTTPS. Cloudflare's JSON API needs only curl and one header:
$ curl -s -H 'accept: application/dns-json' \
'https://cloudflare-dns.com/dns-query?name=mailexchange.com&type=MX'
{"Status":0,"TC":false,"RD":true,"RA":true,"AD":false,"CD":false,
"Question":[{"name":"mailexchange.com","type":15}],
"Answer":[{"name":"mailexchange.com","type":15,"TTL":300,"data":"1 aspmx.l.google.com."},
{"name":"mailexchange.com","type":15,"TTL":300,"data":"10 alt3.aspmx.l.google.com."},
{"name":"mailexchange.com","type":15,"TTL":300,"data":"10 alt4.aspmx.l.google.com."},
{"name":"mailexchange.com","type":15,"TTL":300,"data":"5 alt1.aspmx.l.google.com."},
{"name":"mailexchange.com","type":15,"TTL":300,"data":"5 alt2.aspmx.l.google.com."}]}
type 15 is MX. Status is the DNS response code: 0 is NOERROR, 3 is NXDOMAIN, 2 is SERVFAIL. AD is true only when every record was validated with DNSSEC (Cloudflare's DNS-over-HTTPS JSON docs, checked 2026-11-24). Google's resolver has the same kind of API without the header: curl -s 'https://dns.google/resolve?name=mailexchange.com&type=MX'.
Here's how the edge cases look in JSON, run the same day:
# null MX
{"Status":0, ... "AD":true, ... "Answer":[{"name":"example.com","type":15,"TTL":158,"data":"0 ."}]}
# name exists, no MX record (only an SOA in Authority)
{"Status":0, ... "Authority":[{"name":"mailexchange.com","type":6,"TTL":1800, ...}]}
# domain doesn't exist
{"Status":3, ... "Authority":[{"name":"com","type":6,"TTL":900, ...}]}
The JSON format is Cloudflare's and Google's own convenience API. The standard version of DNS over HTTPS (RFC 8484, October 2018) carries binary DNS messages instead, which is what browsers use.
What each answer means
| What you see | What it means | What a sender does |
|---|---|---|
| NOERROR, one or more MX records | Normal. The hosts are the domain's mail servers. | Tries the lowest preference first, then the next. |
NOERROR, a single 0 . | Null MX: the domain accepts no mail (RFC 7505). | Fails at once; RFC 7505 says a rejecting server SHOULD use reply code 556 with enhanced status 5.1.10. |
| NOERROR, no answer (only an SOA) | The name exists but has no MX record. | Falls back to the domain's own A/AAAA address as an "implicit MX" with preference 0 (RFC 5321, section 5.1). If nothing listens there, mail queues and bounces days later. |
| NXDOMAIN | The domain doesn't exist. | RFC 5321: "MUST be reported as an error". Immediate bounce. |
| SERVFAIL or a timeout | The lookup failed (broken DNSSEC, dead name servers). | Treats it as temporary: queues and retries (RFC 5321). |
Two checks finish the job. First, every host in the answer must itself resolve: RFC 5321 says the MX host name "MUST return at least one address record", and RFC 2181 (section 10.3) says it "must not be an alias" (a CNAME). For our first record:
$ dig +short A aspmx.l.google.com
142.251.2.26
$ dig +short AAAA aspmx.l.google.com
2607:f8b0:4023:c0b::1b
$ dig +short -x 142.251.2.26
dl-in-f26.1e100.net.
Second, if the domain has an MX record, senders must not deliver anywhere else: RFC 5321 says they "MUST NOT utilize any address RRs associated with that name unless they are located using the MX RRs". A broken MX is therefore a hard failure, not something the A record quietly rescues. For the mistakes behind most broken answers, see common MX record errors.
What an MX check can't tell you
An MX lookup answers "can this domain receive mail, and where?" It can't tell you whether [email protected] exists. Only Acme's mail server knows that, and it takes an SMTP conversation to ask. That's the gap between DNS tools and verification.
It matters at scale. In Mail Exchange's checks of 779,784 unique business addresses across 200,799 domains (17 Oct to 22 Nov 2026, mostly B2B contact lists), 0.9% sat on a domain that doesn't receive mail, which an MX lookup catches. But 6.7% had perfectly good MX records and the mailbox was still rejected. If you're about to mail a list, verify it with Mail Exchange first: the free trial covers 25 checks, plans start at $49 a month for 10,000 verifications and daily checks on 10 sending domains, and unknown results are refunded.
google.com hosts for Google Workspace, mail.protection.outlook.com for Microsoft 365), but security gateways such as Proofpoint and Mimecast hide the provider behind them. See how to find who hosts a domain's email.Common questions
What is the command to check MX records?
On macOS or Linux run dig MX example.com, or dig MX example.com +short for just the records. On Windows run nslookup -type=mx example.com in Command Prompt, or Resolve-DnsName example.com -Type MX in PowerShell. host -t mx example.com also works on macOS and Linux.
Why does nslookup show my MX records in a different order each time?
DNS servers may return the records of a set in any order, and many rotate them. The order on screen means nothing. Sort by the preference number: senders try the lowest number first and pick at random among records that share a number.
What does MX 0 . mean?
It is a null MX record, defined in RFC 7505. A single MX record with preference 0 and the host "." says the domain accepts no email at all. Senders should fail the message at once instead of retrying. example.com publishes one.
How do I check MX records against a specific DNS server?
Add the server to the command: dig @1.1.1.1 MX example.com, nslookup -type=mx example.com 8.8.8.8, or Resolve-DnsName example.com -Type MX -Server 1.1.1.1. To see what the domain itself publishes, without any cache, query one of its own name servers, found with dig NS example.com.
Does a correct MX record mean an email address exists?
No. MX records show that a domain can receive mail and which servers take it. Whether a particular mailbox exists is only known to that mail server, which takes an SMTP mailbox check to ask.