Key takeaways
- The SPF 10 lookup limit counts
include,a,mx,ptr,exists, andredirect. It does not countip4,ip6, orall. - Nested includes share one global counter. A record with three visible includes can consume many more lookups in the records they reference.
- RFC 7208 says SPF implementations should limit void lookups to two. Exceeding that limit produces
permerror. - SPF
permerrorcannot give DMARC an SPF pass. A passing, aligned DKIM signature can still satisfy DMARC. - The safest operating target is 10 or fewer DNS-querying terms on every evaluated path, with unused includes removed and provider changes monitored.
What SPF lookup count actually measures
SPF is evaluated for a particular connecting IP address and envelope identity, usually the SMTP MAIL FROM domain. A receiver reads the domain's SPF TXT record, follows DNS-dependent mechanisms as needed, and returns a result such as pass, fail, or permerror. A published record can look short while its referenced records create a much longer evaluation.
RFC 7208 defines six DNS-querying terms for the SPF 10 lookup limit: the include, a, mx, ptr, and exists mechanisms, plus the redirect modifier. Each term that is evaluated consumes from the same total. The all, ip4, and ip6 mechanisms do not cause DNS queries during SPF evaluation, so they do not consume this limit. The exp modifier is also outside this evaluation-time limit, although it can cause a later lookup.
The counter is global across recursion. If your root record includes a provider record, and that record includes two more records, the nested terms count toward the original evaluation. They do not receive a fresh allowance of 10. This is why a domain can trigger an SPF too many DNS lookups error even when the root TXT record contains only a few terms.
The limit is a processing safeguard, not a suggestion to publish 11 and hope every receiver continues. RFC 7208 requires an SPF implementation to return permerror when the 10-term limit is exceeded, but it does not prescribe one universal way to handle every SPF result. Receivers may reject or continue with other filtering, so treat 10 or fewer as the safe target.
SPF void lookup limit: a separate failure mode
A void lookup is a DNS query that returns no usable data, such as a NOERROR response with zero answers or an NXDOMAIN response. RFC 7208 says SPF implementations should limit void lookups to two, and that exceeding the limit produces permerror. This is separate from the count of DNS-querying terms: a record can stay under 10 terms and still create too many empty DNS responses.
The practical lesson is to check the targets of include, a, mx, exists, and redirect, not just count words in the root record. Remove stale references and correct misspelled hostnames. Do not assume that an empty target is harmless because it does not authorize a sender.
Why permerror matters to DMARC
SPF permerror means the published policy could not be correctly interpreted. It is not an SPF pass and cannot provide the passing SPF identifier that DMARC needs. If the message relies on SPF for DMARC, an over-limit record can therefore remove that authentication path.
DMARC passes when at least one authenticated identifier passes and aligns with the domain in the visible From header. An aligned DKIM pass can still satisfy DMARC even when SPF is permerror. The DKIM signing domain is the value in the signature's d= tag; alignment then compares that domain with the visible author domain under the domain owner's relaxed or strict setting.
This fallback is not a reason to leave SPF broken. A receiver may apply local handling to authentication errors, and a message can have other authentication, reputation, or policy problems. Use the SPF, DKIM and DMARC basics guide to separate the SPF result from DMARC alignment, then inspect the actual Authentication-Results header for a message.
Example: count an SPF record by hand
Example only. The domains and addresses below use documentation values. Assume the sender IP does not match an earlier mechanism, so the receiver evaluates every relevant branch.
At the root:
example.com. TXT "v=spf1 include:a.example.net include:b.example.net a:mail.example.com mx exists:track.example.com -all"The referenced records are:
a.example.net. TXT "v=spf1 include:c.example.net include:d.example.net ?all"
b.example.net. TXT "v=spf1 include:e.example.net a:relay.example.net ?all"
c.example.net. TXT "v=spf1 ip4:192.0.2.10 ?all"
d.example.net. TXT "v=spf1 mx ?all"
e.example.net. TXT "v=spf1 include:f.example.net ?all"
f.example.net. TXT "v=spf1 ip4:198.51.100.10 ?all"Count the terms on the path:
- Root
include:a.example.net= 1. - Root
include:b.example.net= 2. - Root
a:mail.example.com= 3. - Root
mx= 4. - Root
exists:track.example.com= 5. - Nested
include:c.example.net= 6. - Nested
include:d.example.net= 7. - Nested
include:e.example.net= 8. - Nested
a:relay.example.net= 9. - Nested
include:f.example.net= 10. - The
mxinsided.example.net= 11.
The record is over the SPF lookup count even though the root record has only five DNS-dependent terms. The ip4 mechanisms in c.example.net and f.example.net authorize documentation addresses without adding lookups. The ?all endings in the referenced records allow evaluation to continue for this worked example; they do not add to the count.
A real evaluation can stop early when a mechanism matches, so a static inventory is not always the exact path for every message. That is why you should count each evaluated branch and confirm the sending IP and envelope domain. The Sky SPF Checker can inspect the published record and its available dependencies, but a record-only check is not a message-level SPF result.
How to fix SPF too many DNS lookups
1. Remove unused includes first
List every sending service that still sends mail for the domain. If a provider, old help desk, abandoned newsletter system, or former relay no longer sends, remove its include after confirming that no legitimate route depends on it. This is usually the lowest-risk reduction because it removes a whole dependency tree rather than changing an active mechanism.
Keep a copy of the previous record and publish one combined SPF record. Adding a second v=spf1 TXT record is not a fix; multiple SPF records create their own permanent error. After DNS propagation, inspect the record and the references again.
2. Replace stable a or mx mechanisms with ip4 or ip6
If an authorized sender uses IP addresses that you own or that the provider documents as stable, replace a DNS-based a or mx mechanism with the corresponding ip4: or ip6: value. For example:
v=spf1 ip4:192.0.2.0/24 ip6:2001:db8::/32 -allExample only. Use your real, confirmed sending ranges, not the documentation ranges above. Do not hard-code addresses that can change without notice. Ask the provider how it announces IP changes and keep an update process for any address-based authorization.
3. Never use ptr as a lookup shortcut
Do not add ptr to work around the limit. RFC 7208 strongly discourages the ptr mechanism because it depends on reverse-DNS names controlled by the IP address owner and can require additional DNS work. If a sender can be represented by stable IP ranges, use ip4 or ip6 instead. If it cannot, keep the provider's supported include and reduce other dependencies.
4. Move different senders to subdomains
Separate unrelated sending programs by envelope domain. For example, marketing mail can use bounce.marketing.example.com with its own SPF record, while transactional mail stays on another sender domain. This gives each domain its own SPF evaluation budget and makes ownership clearer.
A subdomain does not make a provider's include smaller, and it does not automatically solve DMARC alignment. Confirm the envelope domain used by the sending system, the visible From domain, and the DKIM signing domain. If you change the envelope domain, re-check alignment and bounce handling before sending.
5. Consider SPF flattening only with maintenance ownership
SPF flattening replaces some include chains with the provider's current ip4 and ip6 ranges. It can reduce lookup consumption, but it turns a provider-managed policy into a copy that you must keep current. Shared sending IPs can change; for example, Amazon SES documents that its shared IP addresses can change at any time. A stale flattened record can stop authorizing legitimate mail or leave unknown infrastructure authorized.
Flatten only when you have a reliable way to refresh the record, review changes, and publish safely. Keep the provider's original documentation and a rollback plan. Flattening is an operational trade-off, not a permanent exemption from the SPF limit.
For a clean starting record, use the SPF Generator, then verify every provider dependency and the final lookup count. If DKIM is the intended fallback for DMARC, check the selector and signing domain with the DKIM Checker as well.
Checklist
- 01Identify the actual SMTP
MAIL FROMor HELO domain and retrieve its single SPF record. - 02Draw every
includeandredirectdependency, including nested records. - 03Count only evaluated
include,a,mx,ptr,exists, andredirectterms; excludeip4,ip6, andall. - 04Check for more than two void lookups and fix missing, empty, or misspelled targets.
- 05Remove unused senders, then replace stable DNS-based mechanisms with owned
ip4orip6ranges where appropriate. - 06Re-check SPF, DKIM, DMARC alignment, and a real message's
Authentication-Resultsheader.
Frequently asked questions
What does SPF permerror mean?
It means the receiver could not correctly interpret the published SPF policy. Too many DNS-querying terms and too many void lookups are two causes covered by RFC 7208. It requires a DNS or policy change rather than a retry of the same record.
What is the SPF 10 lookup limit?
It is the maximum total of DNS-querying SPF terms during one evaluation: include, a, mx, ptr, exists, and redirect. Nested includes share the same global count. ip4, ip6, and all do not count toward it.
How do I fix SPF too many DNS lookups without breaking mail?
Start by removing confirmed-unused includes. Then replace stable, owned DNS-based mechanisms with ip4 or ip6, split unrelated senders onto subdomains, and use flattening only if you can keep provider ranges updated. Re-test each legitimate sending path before tightening the final policy.
What is the SPF void lookup limit?
RFC 7208 recommends a limit of two void lookups, meaning DNS queries that return no data or NXDOMAIN. Exceeding that limit produces permerror for implementations applying the limit. Fix the empty or nonexistent dependencies instead of treating them as harmless.
Can DMARC pass when SPF is permerror?
Yes, but not through SPF. A passing DKIM signature whose signing domain aligns with the visible From domain can satisfy DMARC. Receivers retain discretion over how they handle authentication and permanent DNS errors, so do not rely on one provider's behavior.
Is SPF flattening safe?
It can lower lookup usage, but the copied IP list can become stale when a provider changes its sending infrastructure. Use it only with a refresh and review process, and keep the provider's supported authorization path documented.
Check the source
Rules and policies change, so check the current version before changing a live sending program.
- [1]
- [2]
- [3]
- [4]
