An SPF PermError for too many DNS lookups means that evaluating your SPF record would need more than 10 DNS-querying terms, so the receiving server stops and reports a permanent error instead of pass or fail. Receivers generally treat that as an authentication failure. The fix is to reduce the number of lookups: delete includes you no longer use, replace stable ones with literal ip4 and ip6 ranges, move some senders to a subdomain, or flatten the record with automation.
This guide shows how to count lookups exactly, how to read the error in message headers, and which remedy to try first. Syntax background is in SPF record syntax.
What the error looks like
You will usually see it in an Authentication-Results header or a DMARC report as spf=permerror, sometimes with text such as "too many DNS lookups" or "exceeded 10 DNS lookups". Different receivers phrase it differently. Gmail shows the SPF result when you open the original message; for steps see viewing email headers.
Authentication-Results: mx.example.net;
spf=permerror (example.net: permanent error in processing during lookup of [email protected]: Too many DNS lookups) [email protected];
dkim=pass header.d=example.com;
dmarc=pass header.from=example.comIn this sample DMARC still passes because aligned DKIM passed. If DKIM were missing or misaligned, DMARC would fail as well. The error text is receiver-specific, so treat the sample as illustrative. Background on the header is in the Authentication-Results header.
What counts toward the limit
| Term | Counts? | Notes |
|---|---|---|
| include:domain | Yes | Plus every counted term inside the included record |
| a / a:domain | Yes | One lookup for the A/AAAA record |
| mx / mx:domain | Yes | One for the MX query; the address lookups for each MX host also count against a separate cap of 10 hosts |
| ptr | Yes | Discouraged by RFC 7208; remove it |
| exists:domain | Yes | Often used with macros |
| redirect=domain | Yes | Replaces the record, but the query is counted |
| ip4 / ip6 / all | No | Matched locally with no DNS query |
Two other failure modes produce the same PermError family. More than two lookups that return no records (void lookups), for instance an include pointing to a domain that no longer publishes SPF, also stop evaluation. And a record that includes itself, directly or through a chain, loops until it hits the cap.
How to count lookups yourself
Start with the TXT record, then follow every include and redirect, counting each counted term at each level.
# 1. Your record
dig +short TXT example.com
# 2. Each include, one by one
dig +short TXT _spf.google.com
dig +short TXT spf.protection.outlook.com
# 3. Quick recursive helper (bash): prints every include target
spf() { dig +short TXT "$1" | tr -d '"' | tr ' ' '\n' | grep -E '^(include:|redirect=)' | sed -E 's/^(include:|redirect=)//' ; }
for d in $(spf example.com); do echo "$d"; spf "$d"; doneA worked example makes the arithmetic concrete. Suppose a domain publishes this record:
v=spf1 mx a include:_spf.mailer-one.example include:_spf.mailer-two.example include:_spf.crm.example include:_spf.helpdesk.example ~all| Term | Own cost | Nested cost (assumed) | Running total |
|---|---|---|---|
| mx | 1 | 0 | 1 |
| a | 1 | 0 | 2 |
| include:_spf.mailer-one.example | 1 | 2 (two nested includes) | 5 |
| include:_spf.mailer-two.example | 1 | 1 | 7 |
| include:_spf.crm.example | 1 | 3 | 11 |
| include:_spf.helpdesk.example | 1 | 0 | 12 |
The total is 12, so the record fails at the 11th term. The nested costs in this table are invented for illustration; your providers' real records will differ and can change at any time, which is why a record that passed last year can fail today. The SPF checker performs this count automatically.
Fix 1: remove what you no longer use
- Check each include against your actual senders. Old marketing tools, trial accounts and former helpdesks are the usual culprits.
- Look at DMARC aggregate reports to see which sources really send. See reading DMARC aggregate reports.
- Delete
ptr, and removeaandmxif your mail does not leave from those hosts. - Remove includes for providers that only sign with DKIM and use their own bounce domain; they do not need to be in your SPF.
Fix 2: use literal addresses for stable infrastructure
Servers you own have addresses that rarely change. Replace a or mx with the real ranges.
# before
v=spf1 mx a include:_spf.mailer-one.example -all
# after (costs 1 lookup instead of 3)
v=spf1 ip4:198.51.100.10 ip4:198.51.100.11 ip6:2001:db8:10::/64 include:_spf.mailer-one.example -allDo this only for addresses you control. For third-party providers it is risky, because they add and rotate addresses without telling you; see fix 4.
Fix 3: split senders across subdomains
SPF is evaluated against the envelope sender domain, so each subdomain has its own record and its own budget of 10. Giving the helpdesk, the newsletter tool and the transactional service their own sending subdomains is the cleanest long-term answer. Most providers support a custom return-path domain; see custom return path and alignment and the broader pattern in sending subdomain strategy. DMARC alignment still works in relaxed mode when the subdomain shares the organisational domain, as explained in DMARC alignment.
Fix 4: flatten the record, with caution
Flattening replaces includes with the IP addresses they currently resolve to. It brings the lookup count down to zero for those entries, but it freezes a moving target: when the provider changes its addresses, your flattened record becomes wrong and legitimate mail fails. Only flatten if the record is refreshed automatically, and keep the unflattened source of truth. Also remember the length limits: a single string is capped at 255 characters and the answer should stay small enough for UDP. Details, risks and tooling are in SPF flattening.
| Method | Lookups saved | Risk | Maintenance |
|---|---|---|---|
| Remove unused includes | Several | Very low | Review twice a year |
| ip4/ip6 for your own servers | 1 per replaced term | Low | Update when you renumber |
| Subdomain per sender | Resets the budget | Low | Needs per-sender DNS setup |
| Automated flattening | Most of them | Medium: stale addresses | Requires a service or script that refreshes |
| Hand-flattening a third party | Most of them | High | Do not do this |
Fix 5: lean on DKIM and DMARC
SPF is only one of two ways to pass DMARC. If a vendor signs with your domain using DKIM, mail can pass DMARC even when SPF fails. That is a safety net, not a plan: forwarded and third-party mail is more reliable when both mechanisms work. See DMARC policies before moving to a stricter policy, because PermError on a reject policy can cause lost mail.
Why records grow past the limit
Almost nobody breaks the limit on purpose. Each new tool asks you to add its include, and each include hides a chain of further includes that the vendor can extend at any time. Large mailbox providers and marketing platforms commonly publish records that already consume several lookups on their own, so adding two or three vendors on top of a mailbox suite is often enough to cross 10. Because the nested costs belong to someone else, your count can rise without any change on your side. That is why a periodic recount belongs in your change process, in the same way you would review certificates or domain renewals.
Set a simple governance rule: nobody adds an include without first running the count, and every include carries a note in your DNS documentation saying which team requested it and which stream uses it. When a tool is retired, removing its include is part of the offboarding checklist. This habit prevents most PermError incidents before they reach production. For a deeper look at running several senders from one domain, see multiple vendors on one domain.
Verify the fix
- Edit the TXT record. Keep only one
v=spf1record. - Wait for the TTL of the old record to expire. A lower TTL before the change helps. See DNS TTL for email.
- Run
dig +short TXT yourdomainand recount. - Send a test message to a mailbox you control and read the
Authentication-Resultsheader forspf=pass. - Watch DMARC reports for a week to confirm nothing legitimate is failing.
Troubleshooting
| Symptom | Cause | Action |
|---|---|---|
| Checker says 11 lookups but only 8 includes | Nested includes are counted | Expand each include and count again |
| Record passes in a checker but fails at a receiver | Provider record changed or tool counts differently | Retest now; recount including redirects |
| PermError after adding a vendor | The new include pushed you over 10 | Apply fixes 1 to 3 before adding it |
| Void lookup error | Include points to a domain with no SPF record | Remove or correct the include |
| Two records published | Vendor setup added a second v=spf1 | Merge into one record |
If you operate several sending streams, plan the budget before you add vendors, and send high-volume streams from their own subdomains. If you send through a relay such as MigoSMTP, publish the include value from your DNS setup, and consider putting it on a dedicated sending subdomain so it has its own record.
Find out how many lookups you use Check your SPF record and see the exact lookup count and failing terms.
References and further reading
Frequently asked questions
What does SPF PermError mean?
It means the receiver could not complete SPF evaluation because of a permanent problem in the record, such as exceeding 10 DNS lookups or publishing multiple SPF records.
How many DNS lookups does SPF allow?
Ten terms that cause DNS queries (include, a, mx, ptr, exists and redirect), counted across nested includes. ip4, ip6 and all do not count.
Does PermError make my email go to spam?
It makes SPF count as a failure, which can hurt delivery and cause DMARC to fail if DKIM is also missing or misaligned.
Is SPF flattening safe?
Only when an automated service keeps the flattened addresses current, because provider addresses change. A hand-edited flattened record usually goes stale.
Can subdomains avoid the limit?
Yes. Each sending subdomain has its own SPF record and its own budget of 10 lookups.