How-to guide

How to check an SPF record and fix “too many DNS lookups”

Read an SPF record, stay under the 10-lookup limit, and avoid the mistakes that make SPF fail for everyone.

Email and IT admins5 min readUpdated
Short answer

Look up the TXT record on your domain that starts with v=spf1, then check three things: there is only one, it ends with ~all or -all, and expanding every include takes no more than 10 DNS lookups. Past 10 lookups, or with two SPF records, receivers return permerror and SPF fails for every message you send.

Reading an SPF record

  • v=spf1 starts the record. There must be exactly one TXT record starting with it.
  • include:_spf.google.com allows everyone that domain’s SPF allows. Each email service you use adds one.
  • ip4: and ip6: allow addresses directly and cost no lookups.
  • a and mx allow the domain’s own web or mail servers, one lookup each.
  • ~all (softfail) or -all (fail) at the end decides what happens to everyone else. +all allows the whole internet, so never use it.

Fixing too many DNS lookups

  • Remove includes for services you no longer send with.
  • Replace a and mx with ip4: and ip6: when those addresses rarely change.
  • Send marketing or bulk mail from a subdomain, such as news.example.com, with its own SPF record.
  • Flattening (replacing includes with the IPs they contain) works but breaks silently when a provider changes its addresses. Only do it with a tool that keeps it updated.

Other common mistakes

  • Two SPF records after adding a new service. Merge them into one.
  • Void lookups: includes that point at names that no longer exist. More than 2 is also a permerror.
  • Relying on SPF alone. SPF checks the hidden return-path address, not the From address people see. DMARC ties them together.
Tip: After any change, send a test email to a Gmail address and use “Show original”: it shows SPF, DKIM and DMARC results.

Questions people ask

What is the SPF 10 lookup limit?
RFC 7208 caps the DNS lookups a receiver makes while checking SPF at 10. Include, a, mx, ptr, exists and redirect count; ip4, ip6 and all don’t. Past 10, SPF returns permerror.
Should SPF end with ~all or -all?
Use ~all while you confirm every sender is listed, then -all. Once DMARC is enforcing, the difference matters less.
Can I have two SPF records?
No. Two records starting v=spf1 make SPF fail with permerror. Combine them into one.
How do I validate my SPF record?
Run an SPF checker on your domain. It fetches the record, expands every include, counts lookups and flags syntax errors, void lookups and duplicates.

Sources and further reading

Written by the middle.network team, who build and run these tools. Last checked 2026-11-21.