SPF "too many DNS lookups" (permerror): how to fix the 10 lookup limit
An SPF record lists the servers allowed to send mail for your domain. Receivers evaluate it on every incoming message, and to keep that work bounded, the SPF standard caps how many DNS queries a single check may trigger. The limit is 10. When your record needs more, the result is not a partial pass: it is permerror, and the record stops working as a whole.
This usually happens slowly. A help desk tool, a newsletter platform, an invoicing system and a CRM each ask you to add one include: to the record, and each of those includes may pull in more includes of its own. Nobody sees the count growing until a validator or a bounce reports "too many DNS lookups".
The short answer: count the lookups your record really triggers, remove what no longer sends, move tools that send in bulk to their own subdomain, and replace includes with IP ranges only where the vendor documents them as stable. The details follow. For a refresher on how SPF fits with DKIM and DMARC, see SPF, DKIM and DMARC explained.
What the limit says
SPF is defined in RFC 7208. Its section on DNS lookup limits names the terms that cause DNS queries: the include, a, mx, ptr and exists mechanisms and the redirect modifier. Implementations must limit the total of those terms to 10, and if the limit is exceeded they must return permerror. The ip4, ip6 and all mechanisms do not cause queries and do not count.
There are 2 related limits in the same section. Each mx mechanism may not resolve more than 10 address records, and SPF implementations should limit "void lookups" (queries that return no answer or a nonexistent name) to 2. Exceeding either also produces permerror.
The count is recursive. An include: costs 1 lookup, and everything inside the included record counts too. Microsoft gives the example of an include that points to a record with 3 more includes: 4 lookups in total.
Why permerror matters
RFC 7208 defines permerror as a result meaning the published records could not be correctly interpreted, an error that requires the DNS operator to fix it. What the receiver then does is its own choice. The RFC lists rejecting the message as one option and delivering it with a note as the less intrusive one.
Either way, SPF no longer passes for your domain. That has knock-on effects:
- DMARC can pass only through aligned DKIM. Any service that relies on SPF alone now fails DMARC.
- Large mailbox providers expect authenticated mail from bulk senders, as covered in Gmail and Yahoo sender requirements and in Outlook sender requirements and the 550 5.7.515 rejection.
- Evaluation runs left to right and stops at the first match. Microsoft notes that some messages may validate before the limit is reached while others hit it, so the problem can look intermittent.
How to count your lookups
Start with your own record:
dig +short TXT example.com
"v=spf1 include:_spf.mailprovider.example include:servers.newsletter.example include:mail.helpdesk.example mx a -all"
Here mx and a cost 1 each and each include costs 1. Then query every included name and repeat for anything it includes:
dig +short TXT _spf.mailprovider.example
dig +short TXT servers.newsletter.example
Write down a tree: each include, a, mx, exists, redirect and ptr is 1 lookup, and ip4 and ip6 are 0. While you are there, check 2 more things:
- There is exactly 1 TXT record starting with
v=spf1. RFC 7208 says that more than 1 SPF record also gives permerror. - Every included name still resolves. Microsoft notes that an include that does not resolve or has no SPF record returns permerror.
Your DMARC aggregate reports help with the next step, because they show which sources really send as your domain. Our guide on how to read a DMARC aggregate report explains where to look.
How to bring the record under 10
Work from the cheapest change to the riskiest:
- Remove what no longer sends. Old newsletter tools, a previous mail provider, a web agency's server from years ago. If a source has not appeared in your DMARC reports for months and nobody owns it, its include can go.
- Drop
ptr, andaormxyou do not need. RFC 7208 says theptrmechanism should not be published.aandmxare only needed if your web server or inbound mail servers really send outgoing mail. - Move bulk senders to a subdomain. A newsletter platform can send from
news.example.comwith its own SPF record and its own 10 lookups. Microsoft lists subdomains among its strategies to reduce lookups. Set up DKIM for the subdomain too. - Replace an include with IP ranges only when the vendor documents stable ones. This is called flattening. Microsoft advises it only for vendors with stable, documented addresses and advises against it for Microsoft 365 and any service whose addresses change often. A flattened record that falls out of date fails silently.
- Rely on DKIM. A service that signs with your domain passes DMARC even when SPF does not align. It is the better long term answer for every third party sender.
A cleaned record might look like this:
example.com. TXT "v=spf1 include:_spf.mailprovider.example ip4:203.0.113.0/24 -all"
news.example.com. TXT "v=spf1 include:servers.newsletter.example -all"
A short checklist
- Exactly 1 SPF record per domain or subdomain.
- Lookups counted recursively: 10 or fewer, with room to spare for the next tool.
- No includes that fail to resolve, no
ptr. - Bulk and marketing senders on their own subdomains.
- Flattened IP ranges documented with the date and the vendor page they came from.
- Every third party sender signing with DKIM for your domain.
Where Business Alerts fit
An SPF record rarely breaks on the day someone edits it. It breaks when a vendor changes what its include points to. We watch your SPF, DKIM and DMARC records and the rest of what we guard from the outside every day, without entering your systems. When a record crosses the lookup limit or an include stops resolving, a person reviews it and you get the exact change to make, as described in what happens when we find something. The example dashboard shows how it looks.
More articles
DKIM key rotation: when and how to rotate your selectors
A DKIM key that never changes is a key that stays useful to anyone who obtains it. Selectors let you replace it without a single failed signature. Here is when and how.
Social engineering against finance and HR teams: the warning signs
Finance and HR teams hold the 2 things criminals want most: money and personal data. These are the warning signs to train for and the rules that stop most attempts.
CAA records: deciding which certificate authorities may issue for your domain
A CAA record tells certificate authorities which of them may issue a TLS certificate for your domain. It takes a few minutes to set up and closes a door most companies leave open.