SPF too many DNS lookups: how to fix it without breaking email
SPF allows at most 10 DNS lookups. Go over and the check fails with a permanent error, so any tool that relies on SPF alone fails DMARC. Remove includes you don't need, check which tools actually use your domain for bounces, move senders to subdomains, and only flatten with automatic updates.
What counts toward the limit
When a receiving server checks your SPF record, every mechanism that makes it look something else up in DNS uses one of your 10 lookups. Nested lookups count too: if you include a provider whose record includes three more records, that's four lookups, not one.
| Mechanism | Counts? |
|---|---|
include: | Yes, plus everything inside it |
a, mx | Yes |
exists:, ptr | Yes (and ptr shouldn't be used at all) |
redirect= | Yes |
ip4:, ip6:, all | No |
There's a second, lesser-known limit: no more than two lookups may come back empty. An include pointing at a domain that no longer publishes SPF is a classic way to hit it.
What happens when you go over
The SPF check stops and returns a permanent error, permerror. Most receivers treat that as an SPF failure. On its own that might not sink a message, because DMARC passes if either SPF or DKIM passes and lines up with your From domain. The trouble starts when a tool also isn't signing with DKIM on your domain. Then it has nothing left, and its email fails DMARC.
The nasty part is that nothing breaks on the day you go over. You add one more tool, its include pushes you to 11, and everything keeps sending. Some of it just stops landing.
How to count your lookups
The quickest way is the live check on my homepage: type your domain and it walks the whole record, nested includes and all. You can also do it by hand: open each include, count the mechanisms inside it, and keep going down until you reach plain IP ranges.
Five ways to get back under 10
1. Remove tools you no longer use
Most bloated SPF records are archaeology. The CRM you left two years ago, the support desk from a trial, the newsletter tool someone tested once. Each include is a lookup you're paying for with nothing in return.
2. Check whether a tool even needs to be in your root record
This is the fix most people miss. SPF isn't checked against the address people see in the From line. It's checked against the Return-Path, the hidden bounce address. Plenty of platforms send with their own bounce domain, so their include in your root SPF record doesn't help DMARC at all. For those tools, DMARC passes through DKIM.
To see which is which, send yourself an email from each tool, open it in Gmail, choose Show original, and look at smtp.mailfrom or Return-Path. If it's the tool's own domain rather than yours, SPF alignment isn't happening through your root record anyway.
Before you remove an include, check the tool's own setup screen. Some platforms show your domain as "not verified" without it, even when it isn't doing any work for DMARC.
3. Move a sender to a subdomain
Marketing tools are often happiest on a subdomain like news.yourdomain.com. The subdomain gets its own SPF record with its own 10 lookups, and its reputation is kept a little apart from the mail your team sends every day.
4. Swap a and mx for IP ranges
If you include a or mx because your own server sends mail, and that server's address rarely changes, list it directly with ip4: or ip6:. IP mechanisms cost nothing.
5. Be careful with flattening
Flattening means replacing includes with the IP ranges they currently resolve to. It works until the provider changes its ranges, which they do without telling you. If you flatten, use a service that updates the record automatically. Flattening by hand and forgetting about it is how you end up with a record that's under the limit and quietly wrong.
Check it worked
After the change, send a test from every tool and look at the headers again. You want to see spf=pass or dkim=pass for your domain, and dmarc=pass. Then run the live check once more and confirm you're at 10 or under.
Quick questions
Does ~all or -all affect the lookup count?
No. The all mechanism doesn't trigger a DNS lookup, whichever qualifier you use.
Does every subdomain get its own 10 lookups?
Yes. Each domain's SPF record is evaluated on its own, which is why moving a sender to a subdomain frees up room.
Is a permerror the same as an SPF fail?
Technically no, but most receivers treat it as a failure. For DMARC it means SPF can't help, so the message needs aligned DKIM to pass.
Want me to check your domain?
Run the live check on my homepage, or send me your domain and get a one-page report within one business day. Free.
Run the live check →