DNS and authentication

How to fix SPF "too many DNS lookups" (permerror)

Short answer

SPF allows at most 10 DNS lookups per check. Every include, a, mx, ptr, exists and redirect counts, including the ones nested inside includes. Go over and receivers return permerror, so SPF fails for all your mail. Fix it by removing services you no longer use, replacing a and mx with ip4 ranges, moving email services to their own return-path subdomain, or, as a last resort, flattening includes into IP addresses.

Last checked 16 November 2026

“SPF too many DNS lookups” means your SPF record needs more than 10 DNS queries to evaluate. The SPF standard caps that number at 10, and a receiver that hits the cap stops and returns permerror. Your SPF then fails for every message, which under DMARC is the same as having no SPF at all. The fix is to cut the number of lookups, not to ignore the warning.

What the RFC says

RFC 7208 section 4.6.4 limits the terms that cause DNS queries:

  • The include, a, mx, ptr and exists mechanisms and the redirect modifier each count as one.
  • Implementations “MUST limit the total number of those terms to 10”.
  • Going over returns permerror.
  • Lookups inside an included record count toward your total.
  • Receivers should also allow no more than two void lookups (queries that return nothing), and exceeding that is a permerror too.

ip4, ip6 and all do not cost anything.

Why the limit exists

Each SPF check makes the receiving server perform DNS queries on the sender’s behalf. Without a cap, one message could trigger hundreds of lookups, which would slow mail servers and could be abused to flood DNS servers with traffic. RFC 7208 sets the limit to protect receivers, so they enforce it strictly: there is no grace for an 11th lookup, and big mailbox providers do not make exceptions for well-known senders.

The limit applies per check, not per day or per message size. A record that needs 11 lookups fails every single time.

How to count your lookups

Count by hand, recursively. Take this record:

v=spf1 include:_spf.google.com include:mail.example-crm.com mx a ~all
Term Lookups
include:_spf.google.com 1, plus every include inside Google’s record
include:mail.example-crm.com 1, plus any inside it
mx 1
a 1

Then open each included record to count its nested terms:

dig +short TXT _spf.google.com
dig +short TXT mail.example-crm.com

Any include: you see in those answers adds one more, and you repeat for them. Large providers often use several nested includes, so three or four vendors can reach 10 quickly. A checker tool does the recursion for you; ours is in tools.

Fixes, from safest to riskiest

1. Remove what you no longer use

Old records collect includes for tools you cancelled years ago. Each one still costs lookups, and if the vendor’s domain no longer publishes SPF it becomes a void lookup. Your DMARC aggregate reports show which services actually send as your domain; anything that never appears is a candidate for removal.

2. Drop a, mx and ptr where you can

mx authorizes your inbound mail servers to send. If you use Google Workspace or Microsoft 365, their include already covers outbound mail, so mx is often redundant. a authorizes your web server, which usually should not be sending mail directly. ptr should never be published (section 5.5). If a server you run does need to send, list it with ip4: instead, which costs nothing.

3. Move email services to their own return-path subdomain

This is the best structural fix. SPF is checked against the envelope sender’s domain. If your app email service sends with a return-path like send.acme.com, its SPF record lives on that subdomain and costs nothing on acme.com:

acme.com.        TXT  "v=spf1 include:_spf.google.com ~all"
send.acme.com.   TXT  "v=spf1 include:amazonses.com ~all"

Most transactional and marketing services support a custom return-path (sometimes called a custom MAIL FROM or bounce domain). It still aligns with acme.com for DMARC under relaxed alignment, the default in RFC 7489.

4. Rely on DKIM for some senders

DMARC passes if either SPF or DKIM passes and aligns. A service that signs with your domain via DKIM does not strictly need to be in your SPF record for DMARC to pass. You would still lose SPF as a backup for that service, so treat this as a tradeoff rather than a free win.

5. Flatten, carefully

Flattening replaces includes with the IP ranges they currently resolve to:

v=spf1 ip4:198.51.100.0/24 ip4:203.0.113.0/24 include:_spf.google.com ~all

It gets you under the limit, but providers change their ranges without notice. When they do, your flattened record silently stops authorizing their new servers. If you flatten, use a service that refreshes the record automatically, and never flatten a provider that tells you not to.

Do not split into two records

A tempting shortcut is to publish two SPF records with half the includes each. That makes things worse: two records is its own permerror (section 3.2). If you need structure, use one record with an include: that points at a second name you control, such as include:_spf2.acme.com. That still counts lookups in total, but it keeps the record readable.

How to confirm the fix

  1. Recount the lookups after your edit.
  2. Wait for the old record’s TTL to pass.
  3. Send a test to Gmail and Outlook and check the Authentication-Results header for spf=pass.
  4. Watch the next week of DMARC reports for any service that now fails.

Mailcandor and the lookup limit

Mailcandor never asks you to add an include to your main SPF record. It uses a return-path on send.yourdomain with its own SPF record and bounce MX, so your root record’s lookup count does not change. See the SPF record guide for full syntax.

Questions

What is the SPF 10 lookup limit?

RFC 7208 says SPF checks must stop after 10 mechanisms or modifiers that need a DNS query: include, a, mx, ptr, exists and redirect. Exceeding it returns permerror.

Do ip4 and ip6 count toward the limit?

No. ip4, ip6 and all need no DNS query, so they do not count. That is why replacing lookups with literal IP ranges is one way to get under the limit.

What does SPF permerror mean?

A permanent error: the record cannot be evaluated correctly. Too many lookups, two SPF records, or a syntax error all produce it. Under DMARC, a permerror counts as SPF not passing.

Is SPF flattening safe?

It works, but it is fragile. Providers change their IP ranges without telling you, and a flattened record does not update itself. Use it only with a tool that refreshes it automatically, or prefer subdomains.

What is a void lookup?

A lookup that returns no records or a nonexistent domain. RFC 7208 says receivers should allow no more than two; more also causes permerror. Remove includes for domains that no longer exist.

Related

Send with someone on your side.

Unlimited domains on every plan, a person before any block, and 3,000 emails a month free. Tell us what you send and we set you up within one business day.