How do I fix "SPF too many DNS lookups"?
By Purlock · Updated 2 min read
The short answer
SPF allows at most 10 DNS lookups when a mail server checks your record. Every include, a, mx, ptr, exists and redirect counts, including the ones nested inside your email services' own records. Past 10, SPF returns a permanent error (PermError), which inboxes treat like a fail. Fix it by removing services you no longer use, moving some sending to a subdomain, or carefully flattening includes into IP addresses.
Key points
- The limit counts nested lookups, so one include can cost 3 or 4.
- Nothing warns you when you cross it: email just starts landing in spam.
- Old, unused services are the easiest lookups to remove.
- Warn yourself at 8, so the next tool you add doesn't break it.
What is the SPF 10 lookup limit?
SPF, defined in RFC 7208, lists who may send email for your domain. To check it, a receiving server may need to look up more DNS records: the ones behind each include, a or mx. To stop this being abused, the standard caps those lookups at 10 per check.
There's also a limit of 2 "void" lookups, ones that find nothing. An include for a service whose record was deleted can break SPF even when you're under 10.
| SPF part | Counts as a lookup? |
|---|---|
| include: | Yes, plus every lookup inside it |
| a and mx | Yes |
| ptr | Yes, and it's best avoided |
| exists: and redirect= | Yes |
| ip4: and ip6: | No |
| all | No |
Email deliverability checker
SPF lookups against the limit of 10, DMARC, DKIM and mail servers.
How do I count my SPF lookups?
Counting by hand means opening every include and every include inside those. Google Workspace's include alone costs several lookups, and marketing tools often add 2 to 4 each.
The email deliverability checker does it the way mail servers do, nested lookups included, and shows which part of your record costs the most so you know what to remove first.
How do I reduce SPF lookups?
- Remove services you no longer send from. Old newsletter tools and trial accounts are the usual culprits, and each removal can free several lookups.
- Remove a and mx if your website and inbound mail servers don't send email themselves.
- Move marketing or support email to a subdomain, like mail.yourshop.com, with its own SPF record and its own limit of 10.
- Flatten what's left: replace an include with the IP addresses behind it. It works, but providers change their addresses, so flattened records need updating, ideally automatically.
Don't fix it by deleting your SPF record. No SPF is worse than a long one.
How do I stop it happening again?
Every new tool that sends email for you asks for another include, and nobody checks the total. A monitor that counts your lookups daily and warns you at 8 of 10 gives you room to clean up before the next tool tips you over.
More questions
- Can I have two SPF records?
- No. Two SPF records on the same name make SPF fail. Merge them into one record.
- Does the limit apply to DKIM or DMARC?
- No. The 10 lookup limit is only for SPF.
- Is ~all or -all better?
- With DMARC in place, ~all (soft fail) is common and safe. -all (hard fail) is stricter, and fine once you're sure every sender is listed.