Skip to content
  • There are no suggestions because the search field is empty.

The 10-lookup limit and SPF permerror

SPF lets a check make at most 10 DNS lookups. Every include, a, mx, ptr, exists, and redirect costs one, and so does every one of those inside an included record. If a check goes over 10, the receiver stops and returns permerror, so that check can't produce a pass. Because evaluation stops at the first match, some mail from the same record can still pass, as explained below. That doesn't automatically mean DMARC fails. Mail that carries an aligned DKIM signature can still pass DMARC.

What counts toward the SPF 10 lookup limit

A check may use at most 10 of those terms during SPF evaluation. Going over returns permerror.

Counts (one lookup each) Doesn't count
include, a, mx, ptr, exists, redirect ip4, ip6, all, exp

It's 10 lookup-causing terms in total, not 10 includes and not 10 mechanisms. The limit is a single global limit across the whole evaluation, so the terms inside your includes count too. An include whose record contains three more includes costs four lookups, not one. A phrasing you'll sometimes see, "up to 10 include: tags," is incomplete: nested lookups count as well.

There are two smaller limits as well:

  • mx: a single mx term that would need more than 10 address lookups gives permerror.
  • Void lookups: receivers should stop after two lookups that return nothing (a name that doesn't exist, or exists with no records). The usual cause is an include or a: host that's been deleted.

What each term does is in SPF mechanisms: include, a, mx, ip4, ip6, redirect.

A worked count

Here's a record that looks reasonable:

v=spf1 ip4:192.0.2.10 a mx include:_spf.vendor-a.example include:mail.vendor-b.example include:send.vendor-c.example ~all
Term Lookups
ip4:192.0.2.10 0
a 1
mx 1
include:_spf.vendor-a.example (its record has 3 more includes) 4
include:mail.vendor-b.example (its record has 2 more includes) 3
include:send.vendor-c.example (only ip4 inside) 1
~all 0
Total 10

That's exactly at the limit. Add one more platform's include, or let vendor A add one more nested include on its side, and the record goes to 11 and returns permerror. You didn't change anything; your vendor did. That's why it's worth leaving headroom.

Why the breakage can look random

The limit applies during evaluation, and evaluation stops at the first match. Mail from 192.0.2.10 matches the first term and never touches the includes. Mail from vendor C sits at the end and runs every lookup before it. So one stream passes and another gets permerror from the same record. Don't rely on ordering to stay legal: keep the whole record, fully expanded, at 10 or fewer.

What SPF permerror means

Permerror means the domain's published records could not be correctly interpreted, and someone has to fix DNS. Retrying won't fix it, which is the difference from temperror, a transient DNS problem that may clear on its own. (A receiver that runs out of time evaluating your record should return temperror, not permerror.)

Too many lookups is one cause. The others:

  • More than one v=spf1 record at the same name (Multiple SPF records (why that is invalid)).
  • A syntax error anywhere in the record.
  • An include or redirect pointing at a domain with no SPF record.
  • More than one redirect or exp.

What receivers do with it

That's their policy. Some reject during SMTP with reply code 550 and the enhanced status code 5.7.24 (SPF validation error). Over-limit messages can also be rejected with a non-delivery report such as "The message required too many lookups." Others deliver the message and treat SPF as not passing.

Error messages vary, and some are misleading. Error messages might include warnings that you don't have an SPF record, even if you do have one. Gmail also has a 5.7.24 message saying the SPF record has one or more suspicious entries; what triggers that wording isn't defined, so don't assume it means the lookup limit.

What it means for DMARC

DMARC needs an SPF pass on a domain aligned with the From address. There is no alignment without an SPF pass, so permerror takes SPF out of the picture. DMARC can still pass through aligned DKIM. A stream that relied on SPF alone, though, now fails DMARC, and at enforcement that stream is the one you'll hear about (Mail started failing after we published DMARC).

You'll usually spot permerror in your DMARC aggregate reports, which carry the SPF result per sending source (walk-through in A field-by-field walk-through of a DMARC aggregate report).

How to get back under the limit

Work through these in order. The fix-it walkthrough for the "spf too many dns lookups" error is in SPF permerror: too many DNS lookups.

  1. Remove senders you no longer use. Drop any include for a third party that no longer sends mail for your domain, and review the record periodically.
  2. Remove duplicates and costly terms. Two includes that cover the same service, or a and mx that duplicate an ip4: you already have. Replace a and mx with ip4:/ip6: for your own fixed servers.
  3. Move some senders to a subdomain. A marketing platform sending as news.example.com with its own SPF record gets its own 10-lookup budget. With relaxed alignment, an SPF or DKIM pass for news.example.com still aligns with a From address at example.com (Identifier alignment for SPF and DKIM, Shared domains and multi-service setups).
  4. Use aligned DKIM instead of an include. If a vendor can sign with your domain, its mail can pass DMARC without its include in your record at all (SPF include vs DKIM from the vendor).
  5. Consider flattening, below, only if the steps above aren't enough.

What about SPF flattening?

SPF flattening means replacing include: mechanisms with the resolved IP addresses to reduce DNS lookups. It isn't part of the SPF standard itself. It's a publishing technique: you replace an include: with the ip4:/ip6: ranges it currently resolves to, and those don't count toward the limit.

It works, with real costs:

  • The IPs go stale. When the vendor changes its infrastructure, your record still lists the old addresses, and legitimate mail starts failing SPF with no warning.
  • You take over the vendor's job. An include updates itself; a flattened list only changes when you change it.
  • The record gets longer, which pushes against DNS size guidance.
  • Automated flattening services solve the staleness problem by adding another dependency.

If you flatten at all, keep these limits in mind:

  • Flatten only vendors with stable, documented IP ranges, and only when subdomains and consolidation aren't feasible.
  • Don't flatten Microsoft 365 (include:spf.protection.outlook.com). Its sending infrastructure uses dynamic IP addresses that change frequently. The same goes for any cloud service with changing IPs.
  • If you do flatten, document what you replaced and when, watch the vendor's documentation, review the entries at least quarterly, and test after each change.

Flattening isn't required, and it isn't a best practice by itself. Treat it as the last step.

Mistakes worth avoiding

  • Counting only your top-level includes and ignoring the nested ones.
  • Leaving includes for vendors you've stopped using.
  • Include loops (A includes B, B includes A), which burn through the limit.
  • Includes or a: hosts that no longer resolve, which trip the void-lookup limit.
  • Flattening Microsoft 365 or another dynamic service, then forgetting about it.
  • Treating "it works at Gmail" as proof the record is fine. Receivers differ, and the first-match effect means one test message proves little.

More SPF slips are in Common SPF mistakes.

Free DMARC account

Turn raw DMARC reports into a readable dashboard

Point your rua address to our platform and read the results by sender and source instead of opening XML files.

  • Results grouped by sending source
  • SPF, DKIM and alignment results per sender
  • The original XML reports are still there to download

Create a free DMARC accountTalk to an expert

FAQ

What does SPF permerror mean?

Your SPF record can't be interpreted, so SPF can't pass. Someone has to fix the DNS record; waiting won't help.

Is it 10 includes or 10 lookups?

Ten lookup-causing terms in total (include, a, mx, ptr, exists, redirect), including the ones inside your includes.

Does permerror mean my mail bounces?

It depends on the receiver. Some reject, some deliver and treat SPF as not passing. Either way, SPF isn't passing.

Will DMARC fail if SPF has a permerror?

Only if DKIM doesn't pass with alignment either.

What's the difference between permerror and temperror?

Permerror means the record itself is broken and needs fixing. Temperror is a transient DNS problem that may clear on retry.

Is SPF flattening safe?

It can work for vendors with stable IP ranges, but flattened IPs go stale. Try cleanup, subdomains, and aligned DKIM first, and don't flatten Microsoft 365.