SPF Record Too Many Lookups: How to Fix It

By Bug Circuit Security Team
SPF Record Too Many Lookups: How to Fix It

Is your own website affected? Check it free in 2 minutes.

Passive outside check only. Nothing is attacked, no signup.

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, ptr or exists term 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). An include: that points at a domain with no SPF record is different. It is an immediate permerror (section 5.2).
  • One SPF record per domain. Two records starting with v=spf1 cause a permerror. 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 recordCounts as a lookup?Notes
include:YesPlus every include nested inside it
aYesLooks up your domain's address record
mxYesLooks up your mail servers
exists:YesRarely needed for small sites
ptrYesSlow and discouraged by the standard. Remove it.
redirect=YesCounts like an include
ip4: and ip6:NoFixed addresses, no DNS needed
all (~all, -all)NoThe 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.

  1. Read your current record:
dig +short TXT example.com

On Windows: nslookup -type=TXT example.com. Find the line starting with v=spf1.

  1. Count each include, a, mx, exists and redirect. That is your first-level total.
  2. 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.

  1. 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 mx and a add 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.

  1. 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.
  2. Remove a, mx and ptr unless your own web or mail server really sends mail for the domain. Many sites that use Google Workspace or Microsoft 365 don't need mx in SPF.
  3. 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.
  4. Move it to a subdomain if a service is needed but costly. Newsletters, help desks and store notifications often work well as news.example.com or support.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.
  5. Flatten it only as a last resort. Flattening means replacing an include with the raw ip4: 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

  1. Save your current record. Copy the full text somewhere safe so you can roll back.
  2. List every service that sends mail as your domain. Ask your team. Check the outbox of your website forms, shop, invoicing and newsletters.
  3. Edit the existing TXT record. Don't add a second one. Two v=spf1 records break SPF.
  4. Keep ~all while you test. The ~all is a soft fail. Switch to -all (hard fail) later, once you are sure every sender is listed.
  5. Wait for DNS to update, usually minutes but sometimes a few hours, then re-run your count.
  6. Send test emails from each service to a personal Gmail address. Open the message, choose Show original, and look for SPF: PASS. Also check DKIM: PASS and DMARC: PASS. Services that use their own bounce domain can show SPF: PASS even 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, ptr and redirect count. ip4, ip6 and all don't.
  • Nested includes count too, and Google Workspace alone uses about four, so count your record with dig or a checker.
  • Remove unused services and unneeded a and mx first. 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.

Want certainty, not guesswork?

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

Frequently asked questions

What happens if my SPF record has too many lookups?
The receiving server treats your SPF as a permanent error (permerror), so SPF counts as failed. Your mail may go to spam or be rejected, depending on the receiver. DMARC may still pass through DKIM, but you should not depend on that.
How do I fix an SPF record with too many lookups?
Count your lookups, then remove services you no longer use and unneeded `a` and `mx` entries. If you are still over 10, move heavy senders such as newsletters or a help desk to a subdomain with its own SPF record. Use flattening only through a managed service that keeps IPs up to date.
Can I have more than one SPF record for a domain?
No. A domain must have only one TXT record that starts with `v=spf1`. Two records cause a permanent error, so merge them into a single record with all your includes.
Why is my SPF record too long?
Tools flag a record as too long when it is over 255 characters and was not split into several strings, or when the full answer is too big for one 512-byte DNS packet. Long records usually come from many includes or hand-pasted IP lists. Remove old services and merge duplicates to shorten it.
Does include:_spf.google.com count as one lookup?
Not on its own. The include itself counts as one lookup, and each list it points to counts as well. At the time of writing that is about four lookups in total, though Google can change this. Check it with `dig +short TXT _spf.google.com`.

Keep reading

See what attackers see, for free

Run the free passive check on your website. No login, no impact on your site, results in seconds.

Ready for the full manual audit? See pricing

Published by Bug Circuit. Written with AI assistance and reviewed for accuracy before publishing.