Skip to content
Foxcolab

SPF too many DNS lookups: fix the 10-lookup limit

Why an SPF record returns PermError once it needs more than 10 DNS lookups, how to count the lookups by hand with dig, and five fixes in the order to try them.

9 min read
On this page13 sections

In short

An SPF check may trigger at most 10 DNS-querying terms: include, a, mx, exists, redirect and ptr, counted across every nested record. The eleventh returns PermError, and SPF can't pass for that mail. Count your record by following each include with dig. Then remove unused senders, replace a and mx with ip4 or ip6, move a sender to a subdomain, or let aligned DKIM carry it. Flatten only as a last resort.

Key takeaways

  • The limit covers include, a, mx, exists, redirect and ptr. ip4, ip6 and all cost nothing.
  • Nested includes count toward the same total, so a record with five includes can need 13 lookups.
  • Receivers evaluate left to right and stop at the first match. A sender listed early can pass while one listed late gets PermError.
  • Two SPF records on one name is a PermError by itself, whatever the lookup count.
  • A PermError is not a pass, so DMARC then depends on an aligned DKIM signature.
  • Flattening removes lookups but freezes a vendor's IP ranges in your record, and vendors change them.

Last reviewed 1 December 2026 by Foxcolab Team

An "SPF too many DNS lookups" error means a receiving server needed more than 10 DNS-querying steps to evaluate your SPF record, stopped, and returned PermError. While the record is in that state, SPF can't pass for the affected mail, and DMARC depends on DKIM alone. The fix is to cut what the record references. This guide shows what counts toward the limit, how to count your own record with dig, and which cuts to try first.

It assumes you know what an SPF record is. If you don't, start with SPF, DKIM and DMARC explained or the SPF glossary entry.

What the 10-lookup limit counts#

Every DNS query in your SPF record is work that a stranger's mail server does for you, on every message. Without a cap, a record could be built to make many receivers flood someone else's DNS servers. So RFC 7208, section 4.6.4 tells receivers to allow at most 10 terms that cause DNS queries during one SPF check, and to return permerror when a record needs more.

TermCounts toward the 10Notes
include:YesOne for the include, plus every counting term inside the included record
aYesOne per a mechanism
mxYesOne per mx mechanism. The address lookups that follow have a separate cap
exists:YesOne per exists mechanism
redirect=YesPlus every counting term in the record it points to
ptrYesDon't publish it at all (see below)
ip4:, ip6:NoThe address is in the record, so nothing is queried
allNoIt matches everything without a query
exp=NoOnly fetched after a fail, to get an explanation text

Five details decide most real cases:

  • Nested includes count. The count is one running total across your record and every record it pulls in (section 4.1). A vendor whose include holds three more includes costs you four. Moving your own mechanisms into a sub-record such as include:_spf2.example.com saves nothing and adds one.
  • Ten is allowed. The eleventh is the error. Fetching your own record at the start is free.
  • mx has a second limit. The MX query costs one of your 10. The address lookups for the mail hosts it returns don't, but an mx that needs more than 10 of them is a PermError by itself.
  • Void lookups are limited to two. A void lookup is a query that comes back empty or with "no such name". After more than two, receivers should return PermError. A typical cause is an a: or mx: naming a host someone deleted long ago.
  • Evaluation runs left to right and stops at the first match (section 4.6.2). A sender listed early can pass while one listed late hits the limit, which makes the problem look random. Microsoft's SPF documentation describes the same effect.

Confirm that lookups are the cause#

PermError is SPF's general "this record can't be interpreted" result, and too many lookups is only one way to get it. It shows up in the Authentication-Results header of a delivered message (RFC 8601), in a bounce, or in a DMARC report:

What the receiver records·Text
Authentication-Results: mx.example.net;
        spf=permerror smtp.mailfrom=example.com;
        dkim=pass header.d=example.com;
        dmarc=pass header.from=example.com

How to read email headers explains each part of that line. Before you count anything, rule out the cause that takes ten seconds to check:

Shell
dig +short TXT example.com | grep -c '^"v=spf1'

The answer must be 1. Two SPF records on one name is itself a PermError (section 4.5): the receiver can't choose between them, so it evaluates neither. A typical way to get there: a new vendor's setup page says "add this TXT record", and you add it next to the one you already have. Merge them into one record with a single v=spf1 and a single all.

A syntax error anywhere in the record is also a PermError. So is an include: whose target has no SPF record (section 5.2), which is what a cancelled vendor's include turns into when that vendor shuts down.

Count the lookups by hand#

The vendors below are invented, so the output is illustrative. Run the same commands against the names in your own record.

1. Fetch your record·Shell
dig +short TXT example.com | grep '^"v=spf1'
Text
"v=spf1 mx a include:_spf.mailhost.example include:spf.crm.example include:_spf.newsletter.example include:mail.helpdesk.example include:spf.invoicing.example ~all"

Seven terms count here: mx, a and five includes. It looks safe. Now open each include, and each include inside it, until a record holds nothing but ip4, ip6 and all.

2. Follow every include to the bottom·Text
$ dig +short TXT _spf.mailhost.example
"v=spf1 include:_netblocks.mailhost.example include:_netblocks2.mailhost.example include:_netblocks3.mailhost.example ~all"

$ dig +short TXT spf.crm.example
"v=spf1 include:_spf.crm-relay.example ip4:198.51.100.128/26 -all"

$ dig +short TXT _spf.newsletter.example
"v=spf1 ip4:203.0.113.64/27 ip6:2001:db8:40::/48 ~all"

$ dig +short TXT mail.helpdesk.example
"v=spf1 a:outbound.helpdesk.example include:_spf.relay.helpdesk.example ~all"

$ dig +short TXT spf.invoicing.example
"v=spf1 ip4:203.0.113.200 -all"

The nested records not shown here hold only ip4 and ip6 ranges. Last, check the mx:

3. Check what mx returns·Text
$ dig +short MX example.com
10 mx1.mailhost.example.
20 mx2.mailhost.example.

Two mail hosts mean two address lookups, well under the separate cap of 10.

Term in the example.com recordLookupsWhy
mx1The MX query
a1The address of example.com
include:_spf.mailhost.example4The include plus three nested includes
include:spf.crm.example2The include plus one nested include
include:_spf.newsletter.example1Only addresses inside
include:mail.helpdesk.example3The include, an a: and a nested include
include:spf.invoicing.example1Only an address inside
Total13Three over the limit

Walk the record from the left and the eleventh lookup is the a: inside the helpdesk include. Mail from the mailbox host, the CRM and the newsletter service matches before that point and passes. Helpdesk and invoicing mail gets PermError. So does every forged message, which should have reached ~all and ended in a softfail.

Google's Admin Toolbox has a Check MX tool that reports the total (Google Workspace Help). Counting by hand shows you which vendor is expensive.

Fix it, in this order#

Start with the changes that can't break anything.

1. Remove senders you've stopped using#

The invoicing vendor in the example was cancelled last year. Its include still costs a lookup and still authorizes that company's servers to send as you. Delete it: 12 left. A mail provider you migrated away from belongs on the same list.

2. Swap the a and mx mechanisms for explicit addresses#

mx authorizes the servers that receive your mail. With hosted email those belong to your provider, whose include already covers the servers that send, so mx is usually redundant. a authorizes your website's address. Keep it only if the web server sends mail itself, and then write the address out as ip4:192.0.2.80. The RFC agrees: prefer ip4 and ip6 over a, and a over mx, unless the addresses change often (section 10.1.2).

That leaves 10, which passes with no room for a vendor to add a nested include. Keep going.

3. Move a sender to its own subdomain#

SPF is checked against the domain in the envelope sender (the Return-Path), and every domain name has its own record with its own budget of 10. Set the newsletter service to send as news.example.com and publish a record there:

Text
news.example.com.  IN  TXT  "v=spf1 include:_spf.newsletter.example ~all"

Remove that include from the root record: 9 left. Under DMARC's default relaxed alignment, news.example.com still aligns with a From address at example.com (RFC 7489, section 3.1.2). Under strict alignment (aspf=s) the From address has to use the subdomain too. Microsoft recommends subdomains for services you don't control, which also keeps their reputation separate from your staff mail.

4. Let aligned DKIM carry a sender#

DMARC needs either SPF or DKIM to pass for the From domain. Look at a real message from the helpdesk tool:

Text
Return-Path: <bounces+4821@mail.helpdesk.example>
Authentication-Results: mx.example.net;
        spf=pass smtp.mailfrom=mail.helpdesk.example;
        dkim=pass header.d=example.com;
        dmarc=pass header.from=example.com

The envelope sender is the vendor's own domain. Receivers check the vendor's SPF record and never read the include in yours. DMARC already passes on DKIM, so the include is three lookups of dead weight. Remove it: 6 left.

If a vendor does use your domain as the envelope sender, dropping its include makes SPF fail for that mail, and DMARC rests on the DKIM signature with no fallback. That's a fair trade for a low-volume tool whose signature you've verified. For bulk mail, check the sender requirements for Gmail, Yahoo and Outlook first, and prefer a subdomain.

5. Flatten, as a last resort#

Flattening means replacing an include with the IP ranges it resolves to at the moment you copy them. ip4 and ip6 cost nothing, so that vendor's lookups drop to zero.

The risk is that those ranges belong to the vendor, and vendors change them without telling you. Your record keeps authorizing addresses the vendor gave up and misses the new ones, so legitimate mail starts failing SPF. Google says its outbound addresses change often and tells customers not to put them in SPF records. Microsoft advises against flattening its include, and suggests flattening only vendors with stable, documented ranges and reviewing the entries at least quarterly.

If you flatten, pick one small vendor that documents fixed addresses, note the date, and re-run dig on a schedule. Hosted flattening services automate the refresh. If one works by having you include a record it hosts, that service decides who may send as your domain.

example.com after the cleanup·Text
example.com.       IN  TXT  "v=spf1 ip4:192.0.2.80 include:_spf.mailhost.example include:spf.crm.example ~all"
news.example.com.  IN  TXT  "v=spf1 include:_spf.newsletter.example ~all"

That's six lookups on the root domain and one on the subdomain. Once the old record's TTL has passed, send a test from each sender to an outside mailbox and confirm spf=pass, or dmarc=pass for the sender that relies on DKIM.

The ptr mechanism, and softfail versus fail#

ptr counts as a lookup, and the RFC's own heading for it says "do not use" (section 5.5). It's slow, it's less reliable than other mechanisms when DNS has errors, and it loads the reverse-DNS servers. Replace it with the addresses or the include it was standing in for.

~all and -all decide what unlisted servers get: softfail or fail. Neither costs a lookup, and a check that errors out never reaches them, so switching won't clear a PermError. Receivers shouldn't reject on softfail alone (section 8.5). They may reject a fail during the SMTP conversation, before DMARC is evaluated (RFC 7489, section 10.1), which can cost you forwarded mail that DKIM would have saved. Vendors differ: Google recommends ~all, and Microsoft recommends -all together with DKIM and DMARC. Stay on ~all while you restructure the record.

How a PermError affects DMARC#

DMARC passes when SPF or DKIM produces a pass for a domain aligned with the From address (RFC 7489, section 4.2). A PermError isn't a pass.

Your setupWhat happens to mail that hits the PermError
The message has an aligned DKIM signatureDMARC passes on DKIM. Delivery is unaffected, but SPF can't act as a backup
No aligned DKIM, DMARC at p=noneDMARC fails. Your policy asks for no action, so the receiver's own filtering decides
No aligned DKIM, DMARC at p=quarantine or p=rejectDMARC fails, and your own policy is applied to your own mail

Receivers can also act on the SPF error directly. RFC 7208 lets them reject with 550 5.5.2 (section 8.7), and Microsoft's documentation says such a bounce can read "The message required too many lookups".

In DMARC aggregate reports, the affected sources show an SPF result of permerror, so the reports are a good place to catch it. See How to read DMARC reports, and fix SPF before you tighten your DMARC policy.

In Foxcolab#

When you connect a domain in the account console (Organization Details → Domains), the SPF record Foxcolab shows is v=spf1 include:foxcolabmail.com ~all. If your domain already has an SPF record, add the include to it. include:foxcolabmail.com costs two lookups: the include and one mx inside it. Run dig +short TXT foxcolabmail.com to confirm the count before you budget.

Foxcolab Mail also signs mail from your domain with DKIM, using your domain and the selector foxcolab, so mail sent through Foxcolab can still pass DMARC while you repair an over-limit record.

The DMARC record Foxcolab suggests uses strict alignment (adkim=s; aspf=s). Under strict alignment, a vendor that sends from a subdomain doesn't align with a From address at your root domain. Either use the subdomain in that vendor's From address, or have the vendor sign with DKIM as your exact domain. The record details are in Configure custom domains, DKIM and DMARC.

Foxcolab's SPF include costs two lookups and its DKIM signing aligns with your domain. To move your domain's mail, see plans or talk to sales.

Frequently asked questions

Is 10 lookups allowed, or do I have to stay under 10?

Ten is allowed. RFC 7208 tells receivers to return PermError when the limit of 10 is exceeded, so the eleventh lookup is the one that fails. A record at exactly 10 has no headroom, though. If a vendor adds one nested include to its own record, yours breaks without any change on your side.

Why does SPF pass for some of my mail and return PermError for the rest?

Receivers read the record from left to right and stop as soon as the sending server matches. Mail from a sender listed early matches before the count reaches 10. Mail from a sender listed late, and any forged mail that matches nothing, runs through the whole record and hits the limit.

Can I split a long SPF record into two TXT records?

No. Two records that start with v=spf1 on the same name produce a PermError for every message. To get a second budget of 10 lookups, move a sender to a subdomain, which has its own SPF record.

Do ip4 and ip6 entries count toward the limit?

No. The address is already in the record, so the receiver has nothing to look up. That is why replacing a, mx or an include with addresses lowers the count. The trade-off is that you have to update the record yourself when the addresses change.

Does an SPF PermError mean my mail is rejected?

Not always. If the message carries a DKIM signature for your From domain, DMARC still passes. Without one, DMARC fails and your own DMARC policy is applied to your mail. A receiver may also reject on the SPF error alone, which the SPF standard allows.

Written by

Foxcolab Team

The Foxcolab team, who build the apps and help people set them up.

More from Foxcolab

Did this guide help you get it done?

One click, no account needed.

Try the tools we write about.

Mail, files, documents, spreadsheets and meetings in one account, with no ads. The free plan is enough to start.

Jump to