SPF permerror: too many DNS lookups
Why SPF records break when they need more than 10 DNS lookups, what counts toward the limit, and five safe ways to get back under it without losing legitimate mail.
An SPF record can make at most 10 DNS lookups while it is being evaluated (RFC 7208). Go over and receivers stop with a permerror, which most treat as an SPF fail. Mail from every sender, including the legitimate ones, loses SPF, and DMARC then depends entirely on DKIM.
What counts toward the limit
| Mechanism | Counts? | Note |
|---|---|---|
include: | Yes, 1 each | Plus everything inside the included record. This is where the count explodes. |
a, mx | Yes, 1 each | mx also looks up each MX host's address |
redirect= | Yes | Plus the target record's lookups |
exists:, ptr | Yes | ptr is deprecated; remove it |
ip4:, ip6:, all | No | Free: no DNS lookup needed |
There is a second, lesser-known limit: no more than two lookups that return nothing ("void lookups"), for example an include of a domain that no longer has an SPF record.
A typical record that breaks
v=spf1 include:spf.protection.outlook.com include:_spf.google.com include:servers.mcsv.net
include:sendgrid.net include:mail.zendesk.com include:_spf.salesforce.com a mx ~all
Six includes plus a and mx already makes 8 at the top level, and the Google, Salesforce and Microsoft includes pull in several more lookups of their own. The total passes 10 without anyone noticing, until mail starts landing in spam.
Five ways to get under 10
- Remove what you no longer use. Old marketing tools, a previous mail host, a decommissioned helpdesk. The cheapest fix and usually enough.
- Drop
aandmxunless the web server or the MX hosts really send mail. With Microsoft 365, the MX host does not send outbound mail; the Microsoft include already covers it. - Replace your own servers with
ip4:. If your on-premises relay has a fixed IP, list the IP instead of a hostname. - Move bulk senders to a subdomain. Send marketing from
news.example.comwith its own SPF record and DKIM. Each subdomain gets its own 10 lookups, and a reputation problem there won't hurt your main domain. - Rely on DKIM where SPF can't align anyway. Many SaaS platforms send with their own bounce domain, so including them in your SPF does nothing for DMARC. If their DKIM signs with your domain, you can often remove their include entirely. Check your DMARC reports before removing.
What about SPF flattening?
Flattening replaces includes with the IP ranges they resolve to. It works, but providers change their IPs without notice, and a stale flattened record silently fails. Only use it through a service that re-flattens automatically, and prefer the five fixes above first.
After you change the record
- Keep exactly one SPF TXT record on the domain; two records is also a permerror.
- Re-check the lookup count, then send test mail to Gmail and Outlook.com and confirm
spf=passin the headers. - Watch DMARC aggregate reports for a week for any sender that started failing.
The checker follows every include and shows how many of the 10 allowed lookups your record uses.