SPF Too Many DNS Lookups: Causes and Fixes
SPF evaluation has a DNS lookup limit. Large collections of include, a, mx, exists and redirect mechanisms can exceed that limit and cause SPF permerror results.
Why SPF DNS lookups matter
An SPF policy can reference other DNS information while it is evaluated. Those lookups protect DNS infrastructure from unbounded recursive evaluation, but they also mean a seemingly short record can become expensive after its includes are followed.
The important number is not simply the number of words in the top-level TXT record. Recursive include and redirect behavior must be considered.
Mechanisms that can consume DNS lookups
Mechanisms such as include, a, mx, ptr and exists can cause DNS queries. redirect can also continue SPF evaluation elsewhere.
Direct IP mechanisms such as ip4 and ip6 do not require the same kind of DNS authorization lookup and can sometimes reduce complexity, although manually flattening third-party infrastructure creates maintenance risk.
- include
- a
- mx
- exists
- ptr
- redirect
How include chains become excessive
A domain might include one mail provider, which includes another policy, which then includes several regional policies. The root SPF record can therefore look simple while evaluation reaches many DNS-dependent terms.
Removing obsolete senders and unnecessary includes is usually safer than immediately flattening every provider.
Be careful with SPF flattening
Flattening replaces dynamically referenced authorization with explicit IP ranges. This can reduce runtime DNS lookups, but the flattened record can become stale when a provider changes its sending network.
A flatten preview should therefore be treated as diagnostic information rather than a record that should automatically be published.
Free email diagnostics
FreeMailCheck provides free tools for SPF, DKIM, DMARC, DNS, SMTP, TLS, reverse DNS, email headers and sender compliance.
Browse all 61 tools →