SPF "too many DNS lookups" means that evaluating your domain's SPF record needs more than 10 DNS lookups, counting every nested include, and RFC 7208 makes 10 a hard limit. A receiver that reaches the 11th lookup stops with permerror, so any server not matched within the first 10 lookups gets permerror rather than pass, and DMARC never counts permerror as a pass. To fix it, find the branches that cost the most, then remove includes you no longer use, replace a and mx with ip4: ranges, or move a sender to a subdomain. The SPF Record Checker does the counting and names the term where the 11th lookup falls.
Use an SPF record checker to find the 11th lookup
- Open the SPF Record Checker, keep Published record selected and enter your domain under Domain, email address or URL.
- Select Check SPF. The check runs in your browser and sends only the DNS names it needs to Cloudflare's public DNS-over-HTTPS resolver, with Google Public DNS as a fallback.
- Read the meters, such as "12 / 10 DNS lookups" and "0 / 2 void lookups". Over the limit, the Findings card names the 11th lookup and the record it sits in.
- In the Include tree, select Expand all to see what each branch costs, counting the include itself.
- Under Test a sending IP, enter a server's address in Sending IP address and select Test IP to get the result a receiver would see and the lookups that path used.
- To test a fix before publishing, choose Draft record, enter the domain under Domain the record is for, paste the edited record into Draft TXT record and select Check SPF.
Counts assume that no term matches, the most a receiver can need. At 9 or 10 the checker warns that you are close: providers can add nested includes to their own records at any time, so keep some headroom. "At least" means an include depends on the sender; test a sending IP to count it.
SPF record syntax: which terms count toward the limit
An SPF record is one TXT record: v=spf1, then terms separated by spaces. Mechanisms such as ip4: or include: describe senders; a qualifier in front sets the result on a match: + pass (the default), - fail, ~ softfail, ? neutral. Modifiers such as redirect= use an equals sign. Receivers read from left to right, stop at the first match and ignore anything after all.
RFC 7208 section 4.6.4 limits the terms that need a DNS query to 10 per evaluation, including those in every record reached through include: or redirect=:
| Term | Lookups | Notes |
|---|---|---|
include: |
1, plus all lookups inside | Nested includes count too |
a, mx |
1 each | More than 10 MX hosts is a permerror |
ptr |
1 | Deprecated: don't publish it |
exists: |
1 | Usually built with macros |
redirect= |
1 | Followed only when nothing matched and there is no all |
ip4:, ip6:, all, exp= |
0 | Not counted |
The limit counts lookups, not includes. In an example from Microsoft's SPF setup guide, an include whose record holds three more includes costs four. Since receivers stop at the first match, an over-limit record still passes servers matched early and returns permerror for the rest, which makes the error look intermittent.
The same section sets a second limit for void lookups, queries that return no records or NXDOMAIN (the name does not exist). Receivers should allow two; a third is a permerror even when the total is under 10. An include of a domain with no SPF record is a permerror on its own.
Worked example: where the 11th lookup falls
A typical record for example.com after years of added services:
v=spf1 a mx include:_spf.mailsuite.example include:spf.newsletter.example include:_spf.crm.example include:mail.helpdesk.example ~all
The provider names and addresses are placeholders, but the shape is common.
| Term | Costs | Running total |
|---|---|---|
a |
1 | 1 |
mx |
1 | 2 |
include:_spf.mailsuite.example |
1 + 3 nested | 6 |
include:spf.newsletter.example |
1 + 1 nested | 8 |
include:_spf.crm.example |
1 + 2 nested | 11 |
include:mail.helpdesk.example |
1 | 12 |
That is 1 + 1 + 4 + 2 + 3 + 1 = 12. Run through the checker's own code, the record gets the verdict "Invalid SPF record", and the finding names the 11th lookup: include:_spf2.crm.example in the CRM's record. Testing one address per sender shows who is affected:
| Sending server | Before the fix | After the fix |
|---|---|---|
| Mail suite | pass, after 6 lookups | pass, after 4 |
| CRM, first block | pass, after exactly 10 | pass, after 6 |
| CRM, second block | permerror | pass, after 7 |
| Help desk | permerror | pass, after 8 |
| Unlisted server | permerror | softfail |
Most mail still passes, which is how this error goes unnoticed. Forged mail gets permerror as well, so the ~all never applies. Three edits bring the total to 8:
v=spf1 ip4:192.0.2.10 include:_spf.mailsuite.example include:_spf.crm.example include:mail.helpdesk.example ~all
ip4:192.0.2.10replacesafor the web server that sends contact-form mail, saving 1.mxgoes, because the MX hosts belong to the mail suite and its include already covers them, saving 1.- The newsletter moves to news.example.com with its own record,
v=spf1 include:spf.newsletter.example ~all, which uses 2 of that subdomain's own 10 lookups.
Checked the same way in Draft record mode, the edited record gets "Valid SPF record" with "8 of 10 DNS lookups used", and the four real senders in the table pass.
How to fix SPF too many DNS lookups
Work through these in order; the first ones cost nothing.
| Fix | Saves | Trade-off |
|---|---|---|
| Remove includes for services you no longer use | The whole branch | None, once nothing still sends |
Remove duplicate includes and ptr |
1 each | None |
Replace a and mx with ip4: or ip6: |
1 each | Update the record when servers move |
| Move a sender to a subdomain | The whole branch | The service must use that subdomain for bounces |
| Flatten a provider's include into IP ranges | The whole branch | Breaks silently when the provider adds addresses |
Check that each include is needed. SPF checks the domain of the envelope sender (the Return-Path or MAIL FROM address), not the From address people see. Many sending services bounce mail to their own domain or to a subdomain you set up for them, so their include on your main domain can cost lookups and authorize nothing.
A subdomain has its own SPF record and its own 10 lookups, and Microsoft recommends one for bulk mail services you don't control. DMARC still counts SPF there, because its default relaxed alignment only needs the SPF domain and the From domain to share an organizational domain.
Flattening copies a provider's current IP ranges into your record and freezes them: when the provider adds servers, their mail fails and nothing warns you. Microsoft says not to flatten include:spf.protection.outlook.com because its addresses change frequently, and to review any flattened vendor ranges at least quarterly. Flattening your own servers' addresses, which is what replacing a and mx does, is the safe version.
Whoever can sign in to your DNS host can rewrite your SPF record, so protect that account with two-step verification and a long password from the Password & Passphrase Generator; see how to create a strong password.
SPF permerror: the other causes
Each of these also ends in permerror, for every message or only for mail that reaches the faulty term:
| Cause | Example | Fix |
|---|---|---|
| Two SPF records | Two TXT records starting v=spf1 |
Merge them into one |
| Include of a domain with no SPF record | include:spf.oldvendor.example |
Fix the spelling or remove it |
| Syntax error | ip4:192.0.2.0/33 or inlcude: |
Correct the term |
| Third void lookup | a: hosts that no longer exist |
Remove the dead terms |
Two records, a syntax error or redirect= written twice break every message, and the checker names the faulty term. To merge two records, keep one v=spf1, combine the mechanisms and end with a single all, as in v=spf1 include:_spf.mailsuite.example include:spf.newsletter.example ~all.
Not every typo is a permerror. include=_spf.example.net, with an equals sign instead of a colon, is read as an unknown modifier and ignored, so that provider is silently left out. Microsoft lists it among common syntax errors, along with a space after the colon and a trailing dot after the domain; the checker flags all three.
Void lookups and IPv6 senders
Void lookups depend on the sender. For an IPv6 sender, an a: term looks up AAAA records, so a host with only IPv4 addresses is a void lookup. This record works for IPv4 mail:
v=spf1 a:smtp1.example.com a:smtp2.example.com a:smtp3.example.com include:_spf.mailsuite.example -all
If the three hosts have no AAAA records, mail the suite sends over IPv6 hits a third void lookup before it reaches the include and gets permerror. The checker shows "0 / 2 void lookups (IPv6 senders: 3 / 2)". Listing the hosts with ip4: costs no lookups and no void lookups.
Troubleshooting SPF lookup errors
Mail from one service fails while the rest passes
That is the order effect from the worked example: moving the failing include to the front only shifts the failure to another sender, so bring the total to 10 or fewer, ideally with one or two to spare.
A fix you published doesn't show up
Resolvers keep the old record until its TTL runs out, so a change can take that long to reach the checker and receivers. Check edits in Draft record mode before you publish them.
The result is temperror, not permerror
Temperror means a DNS lookup failed, for example a name server that didn't answer; the receiver may accept the message or defer it for a retry. If it repeats for one name, that domain's name servers are the problem, not your lookup count.
~all versus -all, and what DMARC sees
| Ending | Unlisted servers get | Use it |
|---|---|---|
-all |
fail | Every sender listed, DKIM in place |
~all |
softfail | While you confirm senders, or by choice |
?all |
neutral | Testing only: it means no policy |
+all |
pass | Never: anyone can send as you |
RFC 7208 says a softfail should not be rejected on that basis alone; a fail is left to the receiver. Under DMARC, only an aligned SPF pass counts (RFC 9989, which replaced RFC 7489 in May 2026), so fail, softfail and permerror look the same and your DMARC policy decides.
The big providers disagree. Google recommends ~all for Google Workspace; Microsoft recommends -all for Microsoft 365 domains that also use DKIM and DMARC. RFC 9989 adds a caution: some receivers act on an SPF hard fail before DMARC runs, so -all can get forwarded mail rejected even when its DKIM signature would have passed DMARC, and those rejections never reach your DMARC reports. A sensible path is ~all while the reports confirm every sender, then -all if that risk is acceptable.
Either way, sign your mail with DKIM: forwarding changes the sending IP and usually breaks SPF, while DKIM signatures generally survive. Gmail requires SPF or DKIM from every sender, and all three from senders of more than 5,000 messages a day to Gmail accounts. If a DKIM key breaks after a DNS edit, the strict decoder in the Base64 Encoder & Decoder rejects a p= value with stray characters or an impossible length.
Frequently asked questions
How many DNS lookups are allowed in an SPF record?
Ten per check, counting every include, a, mx, ptr, exists and redirect in your record and in every record it includes. Separately, no more than two lookups may come back empty. ip4, ip6 and all cost nothing.
Do ip4 and ip6 count toward the SPF lookup limit?
No. They compare the sender's address directly, so you can list many. The limit is length: a record over 255 characters must be split into several strings, which receivers join without spaces, and the whole DNS answer should stay within 512 bytes. In Draft record mode the checker suggests a split.
Does SPF flattening fix too many DNS lookups?
It removes the lookups but hardcodes addresses the provider can change at any time, after which mail from new addresses fails without warning. Flatten only vendors with stable, documented ranges, never Microsoft 365, and review them regularly.
What does SPF permerror mean?
Permerror is a permanent error: the published record cannot be evaluated, and RFC 7208 says fixing it needs the domain's DNS operator. What happens next is up to the receiver, which may reject the message. DMARC never counts it as a pass, so the message passes DMARC only if DKIM passes and aligns.