New guide: how to warm up a dedicated IP without hurting your reputation. Read now →
Log in
MigoSMTP
Domains and DNSUpdated 4 Nov 2026

SPF PermError: too many DNS lookups, how to count them and how to fix it

Why an SPF record returns PermError when it needs more than 10 DNS lookups, how to count the lookups through nested includes with dig, and the fixes in order of preference, from cleanup to subdomains and flattening.

LF
Written by Lena Fischer
European Deliverability and Privacy Liaison
Reviewed by Mateus Oliveira
  • Published22 Jun 2024
  • Read time7 min
  • Length1,458 words
Share this guide

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.

Limit10 terms that trigger DNS queries per SPF evaluation, counted through nested includes (RFC 7208, section 4.6.4)
What countsinclude, a, mx, ptr, exists and the redirect modifier
What is freeip4, ip6 and all
Side effectMail can fail SPF, and DMARC then depends on DKIM alone

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.com

In 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

TermCounts?Notes
include:domainYesPlus every counted term inside the included record
a / a:domainYesOne lookup for the A/AAAA record
mx / mx:domainYesOne for the MX query; the address lookups for each MX host also count against a separate cap of 10 hosts
ptrYesDiscouraged by RFC 7208; remove it
exists:domainYesOften used with macros
redirect=domainYesReplaces the record, but the query is counted
ip4 / ip6 / allNoMatched 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"; done

A 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
TermOwn costNested cost (assumed)Running total
mx101
a102
include:_spf.mailer-one.example12 (two nested includes)5
include:_spf.mailer-two.example117
include:_spf.crm.example1311
include:_spf.helpdesk.example1012

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 remove a and mx if 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 -all

Do 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.

MethodLookups savedRiskMaintenance
Remove unused includesSeveralVery lowReview twice a year
ip4/ip6 for your own servers1 per replaced termLowUpdate when you renumber
Subdomain per senderResets the budgetLowNeeds per-sender DNS setup
Automated flatteningMost of themMedium: stale addressesRequires a service or script that refreshes
Hand-flattening a third partyMost of themHighDo 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

  1. Edit the TXT record. Keep only one v=spf1 record.
  2. Wait for the TTL of the old record to expire. A lower TTL before the change helps. See DNS TTL for email.
  3. Run dig +short TXT yourdomain and recount.
  4. Send a test message to a mailbox you control and read the Authentication-Results header for spf=pass.
  5. Watch DMARC reports for a week to confirm nothing legitimate is failing.

Troubleshooting

SymptomCauseAction
Checker says 11 lookups but only 8 includesNested includes are countedExpand each include and count again
Record passes in a checker but fails at a receiverProvider record changed or tool counts differentlyRetest now; recount including redirects
PermError after adding a vendorThe new include pushed you over 10Apply fixes 1 to 3 before adding it
Void lookup errorInclude points to a domain with no SPF recordRemove or correct the include
Two records publishedVendor setup added a second v=spf1Merge 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.

Run the SPF checker

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.

Topics#spf#permerror#dns lookups#flattening#troubleshooting
Was this guide helpful?Your answer helps us improve our documentation.

Start sending in minutes.

Create an account, add your domain and send your first email.

Get started Talk to sales