Domain health guide
SPF too many DNS lookups: what it means and how to fix it
An SPF record can be perfectly valid in syntax and still fail for every message. The usual cause is the ten-lookup limit: receivers stop evaluating and return a permanent error, and DMARC then treats SPF as failed.
Where the limit comes from
The SPF specification (RFC 7208) limits evaluation to ten mechanisms and modifiers that cause DNS lookups. The limit exists so that checking one message cannot make a receiver perform an unbounded number of queries.
When an eleventh lookup would be needed, the receiver stops and returns permerror. A permerror is not a soft result: for DMARC purposes SPF has not passed, so the message depends entirely on DKIM.
What counts and what does not
The mechanisms include, a, mx, exists and ptr each count, and so does the redirect modifier. The mechanisms ip4, ip6 and all do not, because they need no query.
The part people miss is that the count is recursive. An include pulls in another domain's SPF record, and every lookup inside that record counts toward your ten. A record with four includes can easily reach twelve once the providers' own records are resolved. There is also a separate limit of two void lookups, which are queries that return no records.
- Count every include, a, mx, exists, ptr and redirect in your own record.
- Resolve each include and count the same mechanisms inside it, and inside anything it includes.
- Add the numbers. If the total is above ten, receivers return permerror.
Four ways to get under the limit
Start with removal. Records collect includes for services nobody uses any more: an old newsletter tool, a previous help desk, a trial that ended. Every include you remove usually saves more than one lookup.
If a provider publishes a narrower include for your region or product, use it instead of the general one. If a service always sends from a small set of fixed addresses, replace its include with ip4 or ip6 entries, which cost no lookups. This is called flattening, and it has a real cost: when the provider changes its addresses your record is silently wrong, so flatten only what you can monitor.
- Remove includes for services that no longer send mail for the domain.
- Replace a and mx with explicit ip4 or ip6 entries if those servers have fixed addresses.
- Move a high-volume sender to its own subdomain with its own SPF record, so it no longer shares the parent domain's budget.
- Flatten a stable include into IP ranges only if you will be alerted when the provider changes them.
Why subdomains help
SPF is evaluated against the domain in the envelope sender, and each domain or subdomain has its own record and its own ten-lookup budget. If marketing mail is sent from news.example.com and invoices from billing.example.com, each can list only the provider it needs.
This also limits damage: a mistake in the marketing record cannot break invoices.
Check the published record, not the one you intended
Counting by hand goes wrong because provider records change. Use a checker that resolves the full include chain and reports the real total, then re-check after any change. CloudSpex resolves the chain and reports the lookup count against the limit, and says plainly when a part of the chain could not be resolved.
A worked example
Take a record that looks modest: two mailbox-related includes, two sending services and the mx mechanism. Written out, it contains five mechanisms that need a lookup. The real total depends on what each included record contains.
Counting it through shows how a record crosses the limit without looking long. The numbers in the example are illustrative, because providers change their records; the method is what matters. Resolve each include, count the lookup mechanisms inside it, and repeat for anything those records include.
example.com. TXT "v=spf1 mx include:_spf.google.com include:spf.protection.outlook.com
include:sendgrid.net include:servers.mcsv.net ~all"
mx 1
include:_spf.google.com 1 + 3 nested includes = 4
include:spf.protection.outlook.com 1 + 1 nested include = 2
include:sendgrid.net 1 + 1 nested include = 2
include:servers.mcsv.net 1 + 2 nested includes = 3
total = 12 -> permerrorCounting it yourself
The count can be done by hand with a DNS lookup tool. It is tedious, which is exactly why records drift past the limit unnoticed.
- Read the domain's own SPF record and write down every include, a, mx, exists, ptr and redirect.
- Look up the TXT record of each include target.
- In each of those, write down the same mechanisms again, and look up any further includes.
- Continue until a record contains only ip4, ip6 and all.
- Add up every mechanism you wrote down. That is the number a receiver counts.
dig example.com TXT +short | grep spf1
dig _spf.google.com TXT +short
dig _netblocks.google.com TXT +shortHow the error shows up
A lookup-limit failure does not produce a bounce that mentions SPF, which is why it goes unnoticed. It appears in three places. In the Authentication-Results header of a received message, the SPF result reads permerror instead of pass. In DMARC aggregate reports, SPF shows as failed for sources you know are in your record. And in practice, messages that also lack an aligned DKIM signature start landing in spam or being rejected under your own DMARC policy.
Because a permerror applies to every message, the effect is not limited to the sender you most recently added. All mail that depends on SPF is affected at once.
Authentication-Results: mx.example.net; spf=permerror (too many DNS lookups) smtp.mailfrom=example.comIncludes you may not need at all
The cheapest fix is to remove includes that never did anything. SPF is evaluated against the envelope sender domain. Many services send with their own domain in the envelope sender, so receivers check the service's SPF record and never consult yours. An include for such a service in your record spends lookups and changes nothing.
To find out, look at the Return-Path header of a message sent by the service. If the domain there is the service's own, or a subdomain you delegated to it, the service does not need to be in the SPF record of your main domain. Its setup guide may still tell you to add the include, because that instruction is written for every configuration.
The void lookup limit
A second, less known limit applies alongside the first. A lookup that returns no records, or a name that does not exist, is called a void lookup, and the specification allows only two of them in one evaluation. Past that, the result is again a permanent error.
This is what turns an old include into a failure. A service is cancelled, its include stays in the record, and one day the provider removes the DNS name behind it. One dead include is tolerated; a second one, or an mx mechanism on a domain without MX records, breaks SPF. Removing unused entries is therefore not just tidying.
Flattening, and what it costs
Flattening replaces an include with the IP ranges it currently resolves to. The lookups disappear because ip4 and ip6 need none. The record is correct on the day it is written and wrong on the day the provider adds or moves a range, and nothing tells you when that happens. Large providers change their ranges without notice.
Some services automate this: they publish a flattened record under a name you include and refresh it when the source records change. That removes the maintenance and adds a dependency, since your SPF now relies on that service staying available and correct. Flatten by hand only for senders with a small, documented, stable set of addresses, and record why it was done.
Using subdomains to split the budget
The lasting fix for a crowded record is to stop sending everything from one domain. Each subdomain has its own SPF record and its own limit of ten.
- Choose a subdomain per sending purpose, for example news for marketing and billing for invoices.
- Configure each service to use that subdomain as its envelope sender or custom return path.
- Publish an SPF record on each subdomain that lists only the one service using it.
- Remove that service's include from the main domain's record.
- Keep relaxed alignment in DMARC, so that mail from a subdomain still aligns with a From address on the main domain.
example.com. TXT "v=spf1 include:_spf.google.com -all"
news.example.com. TXT "v=spf1 include:servers.mcsv.net -all"
billing.example.com. TXT "v=spf1 include:sendgrid.net -all"Why DKIM makes this less urgent
DMARC passes when either SPF or DKIM passes with alignment. A sender that signs with an aligned DKIM key does not depend on your SPF record to pass DMARC. If every third-party service is set up with a custom DKIM domain, an SPF permerror stops being an outage and becomes a weakness.
That is not a reason to leave the record broken, since some receivers weigh SPF separately and forwarding can break DKIM in rare cases. It does change the order of work: when SPF is over the limit and mail is failing, enabling aligned DKIM on the affected senders is often the fastest way to restore delivery while the record is being reduced.
Keeping it from happening again
The limit is usually exceeded without any edit to your own record, when a provider adds a nested include. A record that sits at nine or ten lookups is one provider change away from failing. Aim to stay at seven or below, review the record whenever a sending service is added or removed, and monitor the real count rather than the visible one. CloudSpex follows the include chain on a schedule, reports the measured lookup count and alerts when the record changes or crosses the limit.
Frequently asked questions
Do ip4 and ip6 entries count toward the SPF lookup limit?
No. Only mechanisms that require a DNS query count: include, a, mx, exists, ptr, and the redirect modifier.
Is SPF flattening safe?
It works, but the record becomes wrong as soon as the provider changes its sending addresses. Flatten only senders with stable addresses, and monitor the result.
Does a permerror affect DMARC?
Yes. With a permerror SPF does not pass, so DMARC can only pass through an aligned DKIM signature.
Does the all mechanism count as a lookup?
No. The all mechanism, ip4 and ip6 need no DNS query and do not count toward the limit.
Does the redirect modifier save lookups?
No. A redirect counts as one lookup and everything in the target record counts as well. It is a way to share one record between domains, not a way to reduce the total.
Do receivers really enforce the limit?
The specification requires a permanent error past ten lookups, and major receivers follow it. A record over the limit may appear to work at a receiver that is lenient, which makes the failures look random.
Use public checks as a starting point
CloudSpex reads limited public-facing signals. It does not change DNS, website, certificate, or email settings. Confirm the responsible provider and test relevant changes before applying a remediation.
Editorial details
Author and reviewer: CloudSpex. Sources: public technical standards and provider documentation relevant to the topic. Last reviewed: November 10, 2026. We update guides when the product behavior or the underlying guidance changes.