SPF Record Too Many Lookups: How to Fix It
An SPF record fails with "too many lookups" when checking it takes more than 10 DNS lookups, and you fix it by removing services you no longer use, dropping needless a and mx entries, and moving heavy senders to a subdomain.
This post is for owners who added Google Workspace, Mailchimp, a store's email service or a help desk, and now see an SPF error. You will learn what counts as a lookup, how to count yours with two commands, and how to trim the record safely. There is a before-and-after example and a short decision list at the end.
What the 10-lookup limit means
SPF (Sender Policy Framework) is a DNS TXT record that lists which servers may send email for your domain. DNS is the internet's address book. When a receiving server checks your SPF record, it looks up every include and similar entry, and every entry inside those.
The SPF standard, RFC 7208, section 4.6.4, caps this at 10 lookups. Go over and the check returns a permerror (permanent error). In plain English, SPF is treated as broken.
What that means for you depends on the receiver. Some mail lands in spam, and some may be rejected. DMARC (the policy that tells receivers what to do with failing mail) can no longer count on SPF. It may still pass if DKIM (a cryptographic signature on your mail) passes and matches your domain. Don't rely on that without checking.
SPF record limitations you should know
The 10-lookup limit is the one people hit first, but it is not the only rule. These are the main SPF record limitations:
- 10 lookups maximum. Nested includes count.
- 2 void lookups. A void lookup is a DNS query for an
a,mx,ptrorexiststerm that returns no records or NXDOMAIN (a "no such domain" answer). RFC 7208 says more than two should cause an error (section 4.6.4). Aninclude:that points at a domain with no SPF record is different. It is an immediatepermerror(section 5.2). - One SPF record per domain. Two records starting with
v=spf1cause apermerror. Merge them into one. - 255 characters per string. A single TXT string cannot be longer. Longer records are split into several quoted strings that receivers join back together. Most DNS dashboards do this for you.
- Keep it small. RFC 7208, section 3.4 says the record should be short enough for the DNS answer to fit in one 512-byte packet.
So if your tool says the SPF record is too long, check two things. Look for two records that should be merged, and look for a pile of ip4 entries pasted in by hand. Both are fixable.
What counts as a lookup
Not every part of an SPF record costs a lookup. Here is the quick guide.
| Part of the record | Counts as a lookup? | Notes |
|---|---|---|
include: | Yes | Plus every include nested inside it |
a | Yes | Looks up your domain's address record |
mx | Yes | Looks up your mail servers |
exists: | Yes | Rarely needed for small sites |
ptr | Yes | Slow and discouraged by the standard. Remove it. |
redirect= | Yes | Counts like an include |
ip4: and ip6: | No | Fixed addresses, no DNS needed |
all (~all, -all) | No | The final rule |
This is why an SPF record with multiple includes gets into trouble fast. One include can hide several more. At the time of writing, Google's include:_spf.google.com points to three more lists, so it uses about four lookups on its own. Vendors can change this at any time, so count yours instead of trusting a number from a blog.
How to count your lookups
On Mac or Linux, open a terminal. On Windows, use nslookup.
- Read your current record:
dig +short TXT example.com
On Windows: nslookup -type=TXT example.com. Find the line starting with v=spf1.
- Count each
include,a,mx,existsandredirect. That is your first-level total. - Look inside each include to find the nested ones:
dig +short TXT _spf.google.com
Add any include:, a, mx, exists or redirect terms you see in the answer, then repeat the lookup for each new include.
- Cross-check with a tool. Our email spoofing tool checks how your domain's email setup looks from the outside. Our free website security check also covers DNS and email security. Any dedicated SPF checker will show the full lookup tree.
If your count is 11 or more, or the checker says permerror, keep reading.
Before and after: a real-looking example
Here is a small business that has piled up services over the years. The domain is a placeholder.
Before (11 lookups, fails):
v=spf1 mx a include:_spf.google.com include:servers.mcsv.net include:sendgrid.net include:mail.zendesk.com include:spf.mtasv.net include:spf.protection.outlook.com ~all
The rough count is mx (1), a (1), Google (about 4), Mailchimp (1), SendGrid (1), Zendesk (1), Postmark (1) and Microsoft 365 (1). That adds up to 11. The numbers are illustrative, so verify with your own checker.
The owner then found out three things:
- Email moved to Google Workspace two years ago, so the Microsoft 365 include is leftover.
- The website server does not send email, so
mxandaadd nothing. - Postmark is not used any more.
After (6 lookups, passes):
v=spf1 include:_spf.google.com include:servers.mcsv.net include:sendgrid.net ~all
The help desk (Zendesk) now sends from support.example.com. That subdomain gets its own record:
v=spf1 include:mail.zendesk.com ~all
This only works if Zendesk is also set up to send mail from support.example.com. In Zendesk's settings, that means setting the From address to the subdomain and setting the custom return-path or sending domain (the address bounces go to) to match.
Each subdomain has its own 10-lookup budget. Always check your vendor's current instructions first, because the exact include name can differ by plan.
Decision list: remove, flatten, or move to a subdomain
Work through these in order. Stop as soon as you are under 10, ideally with a few to spare.
- Remove it if the service is no longer used. Check old newsletter tools, past CRMs, abandoned help desks and old mail hosts. This fixes most cases.
- Remove
a,mxandptrunless your own web or mail server really sends mail for the domain. Many sites that use Google Workspace or Microsoft 365 don't needmxin SPF. - Check whether the include is needed at all. Some services send using their own bounce domain, so an include on yours may do little. They authenticate with DKIM instead. Follow the vendor's docs and test before removing.
- Move it to a subdomain if a service is needed but costly. Newsletters, help desks and store notifications often work well as
news.example.comorsupport.example.com. This also keeps a marketing tool's reputation away from your main email. Moving a service to a subdomain only helps if the service actually sends mail from that subdomain. That means setting its From address and its custom return-path or sending domain in the vendor's settings. - Flatten it only as a last resort. Flattening means replacing an
includewith the rawip4:addresses it contains. It saves lookups, but vendors change their IP addresses, and your hand-copied list goes stale without warning. Real mail then starts failing. Use flattening only through a managed service that updates it automatically, never as a one-time paste.
How to make the change safely
- Save your current record. Copy the full text somewhere safe so you can roll back.
- List every service that sends mail as your domain. Ask your team. Check the outbox of your website forms, shop, invoicing and newsletters.
- Edit the existing TXT record. Don't add a second one. Two
v=spf1records break SPF. - Keep
~allwhile you test. The~allis a soft fail. Switch to-all(hard fail) later, once you are sure every sender is listed. - Wait for DNS to update, usually minutes but sometimes a few hours, then re-run your count.
- Send test emails from each service to a personal Gmail address. Open the message, choose Show original, and look for
SPF: PASS. Also checkDKIM: PASSandDMARC: PASS. Services that use their own bounce domain can showSPF: PASSeven after you remove their include from your record, so DKIM and DMARC passing is what proves your own domain still passes.
For Google Workspace, Google documents the correct record in its SPF setup guide.
Mistakes to avoid
- Deleting an include you still need. Confirm before you remove. Newsletter and invoice emails are easy to forget.
- Creating a second SPF record while trying to add a service.
- Pasting IP addresses by hand and forgetting about them for a year.
- Using
+all. This lets anyone send as you. Never use it.
Key takeaways
- SPF allows 10 DNS lookups.
include,a,mx,exists,ptrandredirectcount.ip4,ip6andalldon't. - Nested includes count too, and Google Workspace alone uses about four, so count your record with
digor a checker. - Remove unused services and unneeded
aandmxfirst. That usually solves it. - Move busy senders such as newsletters or help desks to a subdomain with its own record.
- Avoid hand-flattened IP lists, keep one SPF record per domain, and test with real emails after each change.
Next step
Fixing SPF stops one kind of email problem, but it is only one part of your site's security. A Bug Circuit audit is a manual test by a real person that ends in a written report with every issue and how to fix it. The Essential plan is $49 one-time for one website. It is a focused small-site audit, not a compliance certificate or a multi-week enterprise pentest. If you are curious how this differs from a scanner, read manual vs automated penetration testing.
A real human security engineer audits your whole site by hand and sends a full report: every issue, its severity, and the exact fix. From $49, with a 14-day money-back guarantee.
See pricing