Email Deliverability

SPF PermError: Too Many DNS Lookups, and How to Fix It

InboxSure··Updated ·6 min read

Your SPF record is published, every sending service is listed, and mail is still failing authentication with spf=permerror or a bounce that mentions "too many DNS lookups". This is the most common way a well-intentioned SPF record breaks, and it breaks completely: a PermError is treated by most receivers as if you had no SPF at all, and by a strict DMARC policy as a failure.

Here is what the limit is, how to count your lookups, and the three ways to get back under it.

The 10-lookup limit

The SPF specification (RFC 7208, section 4.6.4) says a receiver must stop evaluating a record after 10 DNS lookups and return a PermError. The limit exists to stop SPF being used to make receivers do unbounded DNS work. It is not configurable, and no major receiver ignores it.

Each of these mechanisms costs one lookup:

  • include:, plus everything inside the included record, recursively
  • a and a:domain
  • mx and mx:domain
  • ptr (deprecated, and slow as well as expensive)
  • exists:
  • redirect=

These cost nothing:

  • ip4: and ip6:
  • all

There is a second, lesser-known limit: no more than two "void" lookups, meaning includes or mechanisms that point at a name with no record. Two broken includes are enough to fail the whole record even if the total count is low.

Mechanism costs at a glance

TermLookupsNotes
include:domain1, plus the cost of everything inside that recordThe only term that nests. Where the surprises come from.
a, a:domain1Only useful if that host actually sends mail.
mx, mx:domain1The MX query counts once. Resolving the MX hosts to addresses is limited separately, to 10 hosts, and does not add to the count of 10.
ptr1Deprecated by RFC 7208. Remove it.
exists:domain1Rare outside specialist setups.
redirect=domain1, plus the cost of the target recordReplaces the whole record with another. Counts like an include.
ip4:, ip6:0Free. This is what flattening produces.
all0Free. Always the last term.

Why the count is higher than it looks

The trap is that includes nest. A record like this looks like three lookups:

v=spf1 include:_spf.google.com include:sendgrid.net include:servers.mcsv.net -all

But _spf.google.com includes three further records, so Google alone costs four. Add a CRM, a helpdesk, a billing system and a second marketing tool, and a record with six includes can easily reach 14 or 15 lookups. Nothing warns you when you add the seventh include; the record simply stops working.

To get an exact count you have to fetch every included record and add them up, the way a receiver does. The free SPF checker does this and reports the total against the limit of 10, along with any include that points at a missing record.

An SPF record with its mechanisms expanded and a lookup counter that reaches 11 of 10, ending in PermError
The eleventh lookup is where the receiver stops reading and returns PermError.

A worked count

Take a record that many small companies end up with: Google Workspace for staff mail, SendGrid for transactional mail, Mailgun for an older product, plus a and mx added by a setup guide years ago.

v=spf1 include:_spf.google.com include:sendgrid.net include:mailgun.org a mx -all

Counting the way a receiver counts, term by term. The nested figures below are what the included records looked like when this post was written; providers change them, and the point of the exercise is the method, not the exact numbers.

TermWhat it resolves toLookupsRunning total
include:_spf.google.comA record containing three more includes (_netblocks, _netblocks2, _netblocks3), each of which is IP-only1 + 3 = 44
include:sendgrid.netA record made of ip4: ranges and nothing else15
include:mailgun.orgA record that in turn includes two further Mailgun records1 + 2 = 38
aThe A record of the domain itself19
mxThe MX records of the domain110
-allNothing010

Ten exactly. The record works today. Now the helpdesk team adds include:mail.zendesk.com because the setup guide told them to, and the count is 11 before the helpdesk record is even opened. Every message from every service fails SPF, including the Google Workspace mail that was fine for years. That is what makes this error so confusing: the thing that broke is not the thing that was changed.

Two honesty points about the table. First, the nested counts are the part that moves. Google's record has had three sub-includes for a long time, but any provider can add one, and your count goes up without you changing anything. Second, only a tool that resolves every include at the moment you run it can tell you the real number. Do not count from memory or from a blog post, including this one.

The free SPF checker showing a record expanded into its includes with the lookup total against the limit of 10
The checker resolves every include and shows the total the receiver would reach.

Fix 1: remove what you do not use

Start here, because it is free. Most records that go over the limit contain services that were tried once and never removed, or two tools that do the same job. For each include, ask whether that service still sends mail as your domain. If you are not sure, check the service's own sending settings: many send from their own domain by default and only need SPF if you have set up custom-domain sending.

Also remove ptr if it is there. It is deprecated, counts as a lookup, and most receivers ignore it anyway. If you have a or mx and your web or mail server never actually sends outbound mail, remove those too.

Applied to the worked example: the domain's website sends nothing, and its MX hosts are Google's, which are already covered by the Google include. Dropping a and mx takes the count from 10 to 8, with room for the helpdesk. The trade-off is only the time it takes to confirm that nothing sends from those hosts.

Fix 2: flatten includes into IP addresses

Replace an include: with the ip4: and ip6: ranges it resolves to. IP mechanisms cost no lookups, so a record of nothing but IPs cannot go over the limit.

The catch is maintenance. Providers change their IP ranges, and when they do, your flattened record is wrong until you update it. Only flatten services whose ranges are stable and documented, such as your own servers, or use a tool that re-flattens automatically. Never flatten the big providers by hand; Google, Microsoft and the large ESPs change ranges without notice.

Also watch the record size. A TXT record over 255 characters has to be split into multiple strings, and the whole record should stay under about 450 characters to fit in a single UDP DNS reply. Long flattened records can hit this limit.

In the worked example, flattening Mailgun would save two lookups, but Mailgun's ranges are not something you want to track by hand. Flattening Google would save three and is a worse idea still. The trade-off is clear: you buy lookups with an ongoing maintenance job, and the failure mode when you forget is the same PermError-equivalent silent fail, now affecting one provider at a time.

Fix 3: use subdomains for different senders

The cleanest long-term fix. Each sending service gets its own subdomain with its own SPF record: marketing mail from news.example.com, transactional mail from mail.example.com, your helpdesk from support.example.com. Each record has one or two includes and never approaches the limit.

This also isolates reputation: a problem with one stream does not drag down the others. The only cost is configuring each service to send from its subdomain, and setting the subdomain's DMARC alignment. Our guide to SPF, DKIM and DMARC covers how the three fit together, and should you send email from a subdomain covers naming and the records each one needs.

For the worked example that would mean three records instead of one:

example.com        v=spf1 include:_spf.google.com -all          (4 lookups)
mail.example.com   v=spf1 include:sendgrid.net -all              (1 lookup)
app.example.com    v=spf1 include:mailgun.org -all               (3 lookups)

The trade-offs: every service has to be reconfigured to send from its subdomain, DKIM has to be set up again on each one, and replies to transactional mail now go to a subdomain mailbox unless you set a Reply-To. For a company with more than four or five senders it is still the only approach that does not need revisiting.

A message passing the SPF, DKIM and DMARC checks in turn and ending in the inbox, the spam folder or a rejection
With SPF in PermError, DMARC has only DKIM to lean on. If DKIM is unaligned too, the message fails.

Mistakes that produce PermError without the lookup limit

  • Two SPF records. A domain must have exactly one TXT record starting with v=spf1. Two is a PermError. This usually happens when a second service's setup guide says "add this TXT record" and someone adds it instead of merging it.
  • Two records pasted into one. A record that contains v=spf1 twice is invalid.
  • Typos in mechanisms. includes:, ip: or a missing colon make the term unrecognised, which fails the record.
  • An include pointing at a domain with no SPF record. This is a void lookup, and two of them fail the record.

The SPF checker flags each of these. Re-run it after every change, and once a quarter in any case: a provider adding an include to its own record can push you over the limit without you touching anything.

How to re-check after a fix

  1. Build the new record (the SPF generator writes one from the services you still use), publish it and wait for the old one's TTL to expire. Most DNS hosts default to an hour; some cache for a day.
  2. Run the SPF checker on the domain. Confirm one record, a total of 10 or fewer, and no void lookups.
  3. Send a message from each service to a mailbox you control at Gmail or Outlook.com. Open the headers and find the Authentication-Results line. You want spf=pass next to the domain in the envelope sender. The email header analyzer finds the line for you.
  4. If you have DMARC with a rua address, wait for the next DMARC aggregate report and confirm the spf result is pass for every source. The DMARC checker will tell you whether a rua is set.

Why this matters for deliverability

With a PermError, SPF contributes nothing. If DKIM is also missing or unaligned, DMARC fails, and under a p=reject policy your own mail is rejected. Gmail and Yahoo require bulk senders to authenticate, so a broken SPF record is a direct route to the spam folder. If you suspect that is where your mail is going, the checklist in why cold emails land in spam starts with authentication for that reason.

Frequently asked questions



Ready to clean your email list?

Upload a CSV or XLSX and get every address marked deliverable, risky, undeliverable or unknown, with the reason. Free for lists of up to 50, no card. Nothing is sent to your contacts.