Deliverability and authentication
Fixing the SPF 10-lookup limit error
By mailers.io team Published 5 min read
public/media/blog-fix-spf-lookup-limit-cover.webp You add one more service to your SPF record, and a week later a checker reports “permerror: too many DNS lookups”. Nothing looks wrong in the record. This is the SPF 10-lookup limit, and it catches almost every company that uses several e-mail services. This post explains the rule and the ways out.
If SPF is new to you, start with SPF, DKIM and DMARC explained.
What the limit is
The SPF standard (RFC 7208) lets a receiver do at most ten DNS lookups while it evaluates one SPF record. The aim is to stop a record from forcing a receiver into a long chain of queries. If the check needs an eleventh lookup, the receiver stops and returns a permanent error (permerror). Most receivers treat that like a failure. A second, smaller rule limits “void” lookups, those that return nothing, to two.
The count covers the whole tree. The record at your domain is one lookup; every include: inside it is a lookup for that record, plus every lookup inside the included record, and so on.
What costs a lookup
| Term | Counts toward ten? |
|---|---|
include: |
Yes, plus whatever the included record contains |
a / a: |
Yes |
mx |
Yes, and each MX host is resolved too |
exists: |
Yes |
redirect= |
Yes |
ptr |
Yes (and discouraged by the standard) |
ip4: / ip6: |
No |
all |
No |
This is why a record that looks short can break. include:_spf.google.com costs one, but the record it points to includes more. A large provider’s include can use three or four lookups on its own. Three such includes and your own mx can reach the limit.
Count your lookups
Use an SPF testing tool that reports the number of lookups, or do it by hand.
- Query the TXT record at your domain and copy the
v=spf1line. - For each
include,a,mx,existsandredirect, add one. - For each
include, open the record it points to and repeat steps 1 and 2. - Add up the total. Every MX host named by an
mxmechanism also counts.
Keep the list. You will need it to decide what to remove.
Fix 1: remove what you no longer use
This is the cheapest fix and often enough. Old marketing tools, a trial of a service you dropped, a previous e-mail provider. Compare the record to the services you really send through today. Before you delete an include, check the DMARC aggregate reports (see rolling out a DMARC policy) to confirm that nothing still sends through it.
Fix 2: use ip4 and ip6 for what you control
If you run your own server with a fixed address, list it as ip4:203.0.113.10 instead of a or mx. Addresses cost nothing. This only suits addresses that do not change. Do not do it for a provider’s ranges, which they change without telling you.
Fix 3: split sending across subdomains
SPF is checked against the return-path domain of each message. If application mail, marketing and cold outreach each use their own subdomain, each subdomain has its own SPF record and its own budget of ten. A record at news.example.com needs to list only what sends there. This also keeps reputations apart, which is its own reason to do it; see separate subdomains for marketing and transactional e-mail and the cold-email subdomain strategy.
Fix 4: lean on DKIM
For DMARC you need SPF or DKIM to pass and align, not both. If a service cannot fit in your SPF record, you can leave it out and make sure it signs with DKIM using your domain. The mail still passes DMARC. SPF itself may fail for that service, so you give up a second line of defence, but the delivery check holds.
This is also how mailers.io works. The record that verifies a sending domain in the app is the DKIM record. SPF is only looked up and shown as advice. See adding a sending domain. If you connect an API provider, many return paths belong to the provider, so SPF alignment with your domain is not what carries the result anyway.
Fix 5: flatten, with care
SPF flattening replaces include: entries with the IP addresses they resolve to. The record then costs few or no lookups. The risk is that providers change their addresses. A flattened record you do not update starts to fail mail from the provider’s new servers, and nobody notices until reports show failures.
If you flatten, use a tool or service that re-resolves the includes on a schedule and republishes the record, and keep the original includes written down. There is also a size limit: a single TXT string is limited to 255 characters, and a whole DNS response over UDP is practically limited to around 512 bytes unless EDNS or TCP is used. Long flattened records can be split into several strings, or into a chain of included records on your own subdomains.
Things that do not work
- Two SPF records. More than one
v=spf1record on a domain is an error. Merge them. - Replacing include with redirect.
redirect=also counts. - Hiding lookups behind
ptr. It still counts and receivers may skip it. - Lowering
-allto~all. The error is about evaluating the record, not about the final qualifier.
After the fix
Run the record through an SPF checker and confirm it shows ten or fewer lookups and no void lookups. Send a test message to a mailbox you can inspect and read the Authentication-Results header for spf=pass. Then check the DMARC reports over the next days.
Keep a short note next to the record: which service each include is for and who added it. The next person to add a service will otherwise hit the same limit.
Where this fits with mailers.io
mailers.io sends through servers you connect, so what goes in SPF depends on those providers, not on mailers.io. The platform does not add its own include to your record for mail sent through your servers. Use the provider’s own instructions for each server, and see the sending domains page for how the domain check treats SPF.
Questions and answers
What does the error look like?
Checkers report permerror, 'too many DNS lookups' or 'SPF PermError'. Receivers treat it as an SPF failure.
Does mailers.io count my SPF lookups?
No. When it checks a sending domain it only looks for a v=spf1 record and shows whether one exists. Counting lookups needs an SPF testing tool.
Can I have two SPF records to get around the limit?
No. A domain must have one SPF record. Two records are an error of their own.
Written by the mailers.io team. Published .