HTTPfy
DNS TXT Record Troubleshooting Checklist - SPF, DKIM, DMARC and Verification Fixes

DNS TXT Record Troubleshooting Checklist - SPF, DKIM, DMARC and Verification Fixes

A TXT record holds free-form text at a DNS name. Mail servers read your SPF, DKIM and DMARC policies from TXT records, and services like Google Search Console, Microsoft 365 and Let's Encrypt (for DNS-01 challenges) ask you to publish a token in one to prove you own the domain.

A broken TXT record seldom gives you a useful error. Verification sits on "pending", or mail lands in spam with spf=permerror buried in the headers. Work through the checks below in order. Most broken TXT records fail at step 1 or 2.

Before you start: query the record yourself

Ask DNS what it returns before you change anything in your provider's panel.

dig +short TXT example.com

On Windows, use either of these:

nslookup -type=TXT example.com
Resolve-DnsName -Type TXT example.com

A healthy root domain often returns several TXT records at once:

"v=spf1 include:_spf.google.com include:sendgrid.net ~all"
"google-site-verification=3Xk9...aQ"
"MS=ms12345678"

That output is normal. A name can hold many TXT records. Each service reads the one that starts with its own prefix and ignores the rest.

To skip resolver caches, query the authoritative server for your domain:

dig +short NS example.com
dig +short TXT example.com @ns1.your-dns-host.net

If the authoritative server shows the new value and your resolver shows the old one, the record is fine and you are looking at a cached copy. Jump to step 8.

You can also run the lookup in the browser with our DNS lookup tool.

1. Check the host name

This mistake causes more failed verifications than anything else on this list.

Many DNS panels append your domain to whatever you type in the Name or Host field. If you enter _dmarc.example.com, the panel creates _dmarc.example.com.example.com. Enter only the part to the left of your domain:

  • SPF and site verification: enter @ or leave it blank. Full name: example.com
  • DMARC: enter _dmarc. Full name: _dmarc.example.com
  • DKIM: enter selector1._domainkey. Full name: selector1._domainkey.example.com
  • ACME DNS-01: enter _acme-challenge. Full name: _acme-challenge.example.com

To catch the doubled-domain mistake, query the wrong name on purpose:

dig +short TXT _dmarc.example.com.example.com

If that returns your DMARC record, delete it and recreate it with the short host.

2. Check quotes and pasted characters

DNS stores TXT data as quoted strings. Most web panels add the quotes for you. If you paste a value that already has quotes, some panels store them as literal characters, and dig shows something like "\"v=spf1 ...\"". Remove your quotes and save again.

Also look for characters picked up from email or documents:

  • Curly quotes (“ ”) in place of straight quotes
  • A trailing space or line break at the end of a verification token
  • Non-breaking spaces between SPF mechanisms

A verification token has to match byte for byte. Copy it from the service's setup page into a plain-text editor first if your clipboard came from a rich-text source.

3. Split values longer than 255 characters

A single string inside a TXT record can hold at most 255 bytes (RFC 1035). A record can hold several strings, and SPF and DKIM verifiers join them back together with no separator (RFC 7208 section 3.3, RFC 6376 section 3.6.2.2).

A 2048-bit DKIM public key runs about 400 characters, so it has to be split. Correct output from dig looks like two quoted strings on one line:

$ dig +short TXT s1._domainkey.example.com
"v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv3x..." "...q7XwIDAQAB"

Watch two things:

  • The split point. Verifiers concatenate strings without adding a space. If the break falls between two SPF mechanisms, end the first string with a space, or put one at the start of the second string. Otherwise ip4:192.0.2.1 followed by include:... turns into ip4:192.0.2.1include:..., which is invalid.
  • Two strings vs. two records. "part one" "part two" is one record. Two separate entries in your panel are two records, and the verifier will not join them. Some panels (Cloudflare, Route 53) split long values for you. Others want you to enter the quoted chunks yourself.

A long value cut into three equal pieces joined by links

Keep the full DNS response small too. RFC 7208 advises keeping SPF answers within 512 bytes so they fit in a single UDP packet. Large responses fall back to TCP, and some resolvers and firewalls block or mangle TCP DNS.

4. Publish one SPF record, not two

A domain can have only one TXT record that starts with v=spf1. If a receiver finds two, SPF returns permerror for every message (RFC 7208 section 4.5). This happens when you add a new email service and paste its suggested record next to the old one:

"v=spf1 include:_spf.google.com ~all"
"v=spf1 include:sendgrid.net ~all"

Merge them into one record with one all at the end:

"v=spf1 include:_spf.google.com include:sendgrid.net ~all"

Two more SPF details:

  • Do not publish the old SPF record type (type 99). RFC 7208 removed it, and receivers look only at TXT.
  • Anything after all is ignored. Put all last.

5. Count SPF DNS lookups

SPF allows at most 10 mechanisms and modifiers that trigger DNS lookups during one evaluation (RFC 7208 section 4.6.4). Go over the limit and the result is permerror.

These count toward the 10: include, a, mx, ptr, exists and the redirect modifier. These do not: ip4, ip6 and all.

Nested includes count too. If you include a vendor whose own record includes three more domains, that one include costs you four lookups. Query each include to see what it pulls in:

$ dig +short TXT sendgrid.net | grep spf1
"v=spf1 ip4:167.89.0.0/17 ip4:208.117.48.0/20 ... include:ab.sendgrid.net ~all"

Some providers have flattened their own records. Google's _spf.google.com now lists IP ranges inline, so it costs one lookup. Older guides that say it costs four are out of date.

A tree of lookups that grows past a cut-off line

RFC 7208 also limits "void lookups", queries that return no records or NXDOMAIN. Receivers should fail the check after two of them. An include pointing at a vendor domain you stopped using, which no longer publishes SPF, wastes a void lookup on every message.

If you are over 10:

  1. Remove includes for services you no longer send through.
  2. Replace a and mx with ip4/ip6 entries when your own servers have stable addresses.
  3. Move one sender to a subdomain (for example mail.example.com for your newsletter tool) so it gets its own SPF record and its own 10-lookup budget.
  4. Flatten includes into IP ranges only as a last resort. Vendors change their IP ranges without telling you, and a flattened record goes stale. If you flatten, use a service or script that refreshes it.

6. Choose between ~all and -all

  • -all (fail) tells receivers to reject mail from servers your record does not list.
  • ~all (softfail) tells receivers to accept that mail but treat it as suspicious.

Many receivers now act on your DMARC policy and treat SPF failure as one signal among several. A common setup is ~all in SPF plus an enforcing DMARC policy (p=quarantine or p=reject). With -all, some receivers reject at SMTP time before DMARC gets a chance to pass the message on its DKIM signature, which can drop forwarded mail. Use -all on domains that send no mail at all:

"v=spf1 -all"

Avoid +all. It authorizes every server on the internet to send as you.

7. Check DKIM and DMARC names and syntax

DKIM keys live at <selector>._domainkey.<domain>. Your email provider picks the selector: Google Workspace uses google by default, Microsoft 365 uses selector1 and selector2. You will find the selector in the s= tag of the DKIM-Signature header on a message you sent.

dig +short TXT google._domainkey.example.com

Common DKIM problems:

  • The selector in DNS does not match the s= value the provider signs with.
  • The key was split into two records instead of two strings (step 3).
  • The provider asked for a CNAME (Microsoft 365 and many sending services do) and you created a TXT record with the key pasted in. When they rotate keys, your copy breaks.
  • An empty p= tag. That means "this key is revoked", and verifiers fail every signature that uses it.

DMARC lives at _dmarc.<domain>. The record must start with v=DMARC1, and it must include a p= policy:

$ dig +short TXT _dmarc.example.com
"v=DMARC1; p=quarantine; rua=mailto:[email protected]"

Common DMARC problems:

  • v=DMARC1 is not the first tag, or has a typo such as v=DMARC 1.
  • Two DMARC records at _dmarc. Receivers then apply no DMARC policy at all (RFC 7489 section 6.6.3).
  • rua points to an address at another domain that has not authorized it. The receiving domain must publish example.com._report._dmarc.otherdomain.com with v=DMARC1, or report senders drop your aggregate reports.

If you are starting from zero, publish p=none with a rua address, read the reports for a few weeks, then move to quarantine and reject.

8. Wait out the right cache

"DNS propagation" means resolvers holding cached answers until their TTL runs out. Two caches matter here:

  • The old record's TTL. If the old TXT record had a TTL of 3600, resolvers that fetched it can keep serving it for up to an hour after you change it. Before a planned change, lower the TTL to 300 a day ahead, make the change, then raise it again.
  • Negative caching. If you or the verifying service queried the name before the record existed, resolvers cached the "no such record" answer (RFC 2308). The length comes from your zone's SOA record: the lower of the SOA TTL and its minimum field.

Check the SOA values with:

dig +short SOA example.com

The last number in the output is the negative-cache TTL in seconds. Some providers set it to an hour or more. That explains why verification still fails 20 minutes after you added a record that dig @authoritative-server already shows.

To see how different resolvers around the world answer, use the DNS propagation checker.

9. Look for a CNAME at the same name

A name with a CNAME cannot hold any other records (RFC 1034, RFC 2181). If _dmarc.example.com or a DKIM selector already has a CNAME, your panel may refuse the TXT record, or dig will follow the CNAME and show you the target's TXT data:

$ dig TXT s1._domainkey.example.com
;; ANSWER SECTION:
s1._domainkey.example.com. 3600 IN CNAME s1.domainkey.u123.wl.sendgrid.net.
s1.domainkey.u123.wl.sendgrid.net. 3600 IN TXT "k=rsa; t=s; p=MIGf..."

That chain is correct if you meant to delegate the key to your provider. If you meant to publish your own TXT record, delete the CNAME first.

The root of your domain (example.com) cannot have a CNAME at all, so this only affects subdomains. Some providers offer CNAME flattening at the root, which is a separate feature.

10. Check DNSSEC if lookups fail outright

If dig returns SERVFAIL for your TXT record, compare a validating resolver against one with validation turned off:

dig TXT example.com @1.1.1.1
dig TXT example.com @1.1.1.1 +cd

If the +cd (checking disabled) query succeeds and the normal one fails, your DNSSEC chain is broken. The common cause is a stale DS record at the registrar after a DNS provider move. Receivers that validate DNSSEC treat the result as a temporary error and retry, so mail gets delayed until you fix the DS record.

Keep the records clean afterwards

Once everything passes, keep a short list of each TXT record, which service it belongs to, and who added it. Delete verification tokens and SPF includes for services you have cancelled. Stale includes waste lookups, and stale verification tokens let anyone who controls that old account claim your domain again.

When you change mail providers, update SPF, DKIM and DMARC in the same change and send a test message to a Gmail or Outlook address. Open the original message headers and look for spf=pass, dkim=pass and dmarc=pass in Authentication-Results.