SPF Too Many DNS Lookups and How to Fix the 10 Limit
Your SPF record looks fine in the DNS panel, yet DMARC reports show SPF failing for mail you know you sent.

Your SPF record looks fine in the DNS panel, yet DMARC reports show SPF failing for mail you know you sent. The usual cause is SPF too many DNS lookups: the record asks receivers to resolve more than ten names, and once that happens the whole check returns an error instead of a pass.
This guide shows how to count lookups by hand, why the limit exists, and four fixes that work without paying for a monitoring service. Expect about 30 minutes of work for a typical small company domain with five or six sending services.
Why SPF too many DNS lookups breaks your mail
SPF is defined in RFC 7208, and section 4.6.4 sets a hard ceiling: a receiver evaluating your record may perform at most 10 DNS lookups for mechanisms that need them. The cap exists so that an SPF record cannot be abused to make thousands of mail servers flood someone else's DNS with queries.
When the count goes past 10, the receiver stops and returns permerror. That is not a soft warning. For DMARC purposes a permerror is treated as an SPF failure, so if your DKIM signature is also missing or misaligned, the message fails DMARC outright. With a policy of p=quarantine or p=reject, that mail goes to spam or bounces.
Worse, a record can break without you editing it: a vendor adds a nested include on their side and your total creeps from 9 to 11.
Which mechanisms count toward the limit
- Count one each: include, a, mx, ptr, exists, and the redirect modifier.
- Count zero: ip4, ip6 and all. These are literal values, so no query is needed.
- Nested includes count too. If you include a vendor whose record includes three more names, that single line costs you four lookups.
There is a second, lesser known limit. RFC 7208 also says receivers should allow no more than two "void lookups", meaning queries that return no record or a nonexistent domain. An include pointing at a vendor you cancelled years ago can trip this one even when your main count is fine.
How to count SPF lookups by hand
You do not need a paid checker. A terminal and dig are enough, and doing it once by hand teaches you where the cost is hiding.
- Run dig +short TXT on your domain and copy the line that starts with v=spf1.
- Write down every include, a, mx, ptr, exists and redirect term. Each one is 1.
- For every include, run dig +short TXT on the included name and repeat step 2 for what it returns.
- Keep going until every branch ends in ip4, ip6 or all. Add up the total.
A common small business record looks like this: v=spf1 include:_spf.google.com include:sendgrid.net include:mailgun.org include:servers.mcsv.net mx a ~all. The six top-level terms already cost 6. At the time of writing the Google include pulls in three more names, and several email platforms nest one or two of their own. A total of 12 or 13 is ordinary for a record that "only has six things in it".
A typical audit looks like this.
| Term | Direct | Nested | Total |
|---|---|---|---|
| include: workspace mail | 1 | 3 | 4 |
| include: newsletter platform | 1 | 1 | 2 |
| include: transactional sender | 1 | 1 | 2 |
| include: helpdesk tool | 1 | 0 | 1 |
| mx | 1 | 0 | 1 |
| a | 1 | 0 | 1 |
| Total | 11 |
Before you change anything, confirm what is really failing. Your DMARC aggregate reports will show an SPF result of permerror next to the sending IPs, which proves the lookup count is the problem and not a missing IP.
Four fixes that bring the count back under 10
1. Delete senders you no longer use
This is the cheapest fix and the one people skip. Ask who still sends from each service. In most audits I run, at least one include belongs to a tool that was cancelled: an old CRM, a trial of a second newsletter platform, a form builder. Removing a dead include saves its full nested cost and also clears any void lookup it caused.
2. Drop the a and mx mechanisms when they add nothing
Many records carry a and mx out of habit. If your website host does not send mail, a is wasted. If your inbound MX belongs to the same provider you already include, mx is a duplicate. Each removal saves 1. Check your outbound mail logs or the Received headers first; our guide on reading email headers to trace a delivery problem shows which server really handed off a message.
3. Replace a stable include with ip4 ranges
If one of your senders is a single VPS or an on-premises relay with a fixed address, write it as ip4:203.0.113.25 instead of an include or a lookup. That costs zero. Only do this for addresses you control. For a third party, their published IPs are their business, and they will change without telling you.
4. Move bulk senders to their own subdomain
This is the structural fix. Send newsletters from a subdomain such as news. on your domain, and receipts from a subdomain such as billing. Each subdomain gets its own SPF record with its own budget of 10 lookups. The root domain keeps only the workspace mail include and maybe one more, which puts it at 5 or 6 with room to grow.
DMARC alignment still works in relaxed mode because the subdomain shares the organisational domain, and complaints about a campaign stay mostly with the subdomain. If the record syntax itself still feels murky, our explainer on email authentication records covers how SPF, DKIM and DMARC fit together.
Why SPF flattening is usually the wrong answer
The most common advice online is to "flatten" your record: resolve every include into a list of ip4 and ip6 ranges and paste them in. Count drops to near zero, problem solved.
I disagree with this for most small teams, for a practical reason. Large senders rotate their IP ranges regularly. A flattened record is a snapshot, and the day your provider adds a new block, mail sent from that block fails SPF. You will not notice until a customer says the invoice never arrived. Hosted flattening services fix this by rewriting your record automatically, but now a third party controls a DNS record that decides whether your mail is trusted, and you pay monthly for it.
Flattening makes sense in one narrow case: a sender with a short, slow-changing list of IPs that you check quarterly. Otherwise, cut dead includes and use subdomains.
Testing the fixed record
Lower the TTL on the TXT record to 300 seconds a day before you edit it, so a mistake can be rolled back in minutes. After the change:
- Recount by hand with dig and confirm the total is 9 or below. Leave at least one lookup spare for vendor drift.
- Send a test message from each service to a mailbox you control and read the Authentication-Results header. You want spf=pass, not permerror or softfail.
- Watch the next seven days of DMARC aggregate reports for any source that changed from pass to fail.
- Set a calendar reminder to recount every three months. Vendors change their records without notice.
Frequently asked questions
What happens if my SPF record has 11 lookups?
Receivers that follow the standard stop at the eleventh lookup and return permerror. For DMARC this counts as an SPF failure, so the message passes only if DKIM is signed and aligned. Some lenient receivers ignore the limit, which is why the problem often looks random.
Does ip4 count toward the SPF lookup limit?
No. The ip4 and ip6 mechanisms contain literal addresses, so the receiver needs no DNS query to evaluate them. The all mechanism is also free. Only include, a, mx, ptr, exists and redirect count.
Can I have two SPF records to get more lookups?
No. A domain must publish exactly one TXT record starting with v=spf1. Two records cause a permerror on their own, which is worse than the problem you were solving. Use subdomains if you need a separate budget.
More in Email Infrastructure
Email Infrastructure
One Click Unsubscribe Headers and the Bulk Sender Rules
I send a monthly note to the people who play on the servers I run. It is not marketing.
Email Infrastructure
Why Email Forwarding Breaks SPF and What ARC Fixes
A reader wrote to me in October about invoices that reached half his list and vanished for the rest.
Email Infrastructure
Warming Up a New Sending Domain Without Hitting Spam
You moved the newsletter to a fresh domain on a Monday, sent 8,000 messages on Tuesday, and by Wednesday Gmail was deferring...