All posts

SPF Too Many DNS Lookups: How to Fix the 10-Lookup Limit

· 8 min read

A freelance web developer working on a laptop at a long wooden table in a quiet library reading room, with an amber notebook and an orange mug beside the laptop

"SPF too many DNS lookups" is an easy way for a perfectly reasonable SPF record to end up broken. Nobody sets out to write a record that fails. You add a service that sends on your behalf, then another, then a third-party tool that someone on the team signed up for, and one day the record crosses a line the standard sets at 10 lookups. The record still looks fine in your DNS panel. It just stops working the way you meant.

This post explains where the limit comes from, which parts of a record count toward it, what happens when you go over, and how to get back under without breaking mail from the services you really use. If you want the basics of SPF first, SPF, DKIM and DMARC explained in plain English is the better starting point.

What the 10-lookup limit is

An SPF record is a line of text in DNS that lists who may send mail for your domain. When a receiving server checks a message, it reads that record and follows it. Some parts of the record tell the receiver to go and look something else up in DNS before it can decide.

RFC 7208, the SPF standard, says an implementation must limit the total number of those DNS-triggering terms to 10 during one evaluation, to avoid unreasonable load on DNS. If the limit is exceeded, the result is a permanent error, called permerror. The same RFC says the limit is tracked as a single global count for the whole evaluation. Terms inside a nested record count toward the same 10, they don't get a fresh allowance.

What counts and what doesn't

The RFC is specific here. These terms cause DNS queries and count toward the limit:

  • include
  • a
  • mx
  • ptr
  • exists
  • the redirect modifier

These do not cause lookups at evaluation time and are not subject to the limit: the ip4, ip6 and all mechanisms, and the exp modifier.

That split is the whole game. A record built from IP ranges costs nothing. A record built from include: statements costs one lookup each, and every include can pull in a record that has its own include terms, all of which count too.

Two details catch people out. First, the mx term counts as one, but the RFC also caps the address lookups it triggers for the MX hosts at 10, and going over that produces permerror on its own. Second, the RFC says implementations should limit "void lookups", meaning lookups that return nothing, to two, and exceeding that also produces permerror. A stale include pointing at a domain that no longer publishes an SPF record is a good way to hit it, because in the RFC's table for include, a recursive result of "none" is itself returned as permerror.

What happens when you go over

A permerror means the receiver could not correctly interpret your published records. The RFC says it signals an error that needs the domain's DNS operator to fix. What the receiver does with that result is up to the receiver, because the standard sets no required handling for any particular SPF result. One provider might treat it like a failed check and another might lean on other signals.

The practical risk is a gap in your authentication. Google's email sender guidelines say all senders need SPF or DKIM, and that senders of more than 5,000 messages a day to Gmail accounts need SPF, DKIM and DMARC. A broken SPF record weakens one of the checks you were counting on. DKIM may still carry a message, but DMARC passes when either SPF or DKIM passes and aligns with your From domain, so losing SPF leaves you with a single path. We go through how the pieces fit together in DMARC policy explained.

Why you hit SPF too many DNS lookups

It usually isn't carelessness. Each tool that sends mail for you asks you to add its own include. A company with a mailbox provider, a transactional email service, a newsletter tool, a support desk and a CRM can reach the limit without anyone making a mistake. Add an old mx term from a migration and an a term for a server that was retired two years ago, and you're over.

Two colleagues at a high counter in a logistics office, looking together at an open laptop
Counting lookups is easier with two people and a list of what actually sends mail.

Step 1: count what you have

Before you change anything, find out where you stand.

  1. Get the current record. It's the TXT record on your domain that starts with v=spf1. A domain must not publish more than one, and the RFC says a receiver that finds more than one SPF record returns permerror, so check that first.
  2. Walk the record from left to right and count every include, a, mx, ptr, exists and redirect.
  3. For each include, look up the record it points to and count the terms inside it that cost lookups too. Keep going until there are no more nested includes.
  4. Compare the total with 10.

Doing it by hand is slow, so run the domain through a checker. The free deliverability checker tests SPF, DKIM, DMARC, MX and blacklists live. Its SPF check looks at whether there is exactly one SPF record, whether it ends in ~all or -all, and whether it stays under the 10-lookup limit.

A live result from the free deliverability checker for inboxrampup.com, showing the 0–100 score and each check with a plain-language summary (live check)
In InboxRampUp's free checker: a live check of inboxrampup.com, shown with its real result.

Step 2: remove what no longer sends

The cheapest fix is deleting terms. Go through the record and ask of each one whether that service is still sending mail for this domain today. Old marketing tools, a trial that ended, a server that was decommissioned. Each one you remove gives back at least one lookup, and often several, because a provider's include can fan out into more.

Check your sending tools and mail logs before you delete anything. Taking a live service out of SPF turns a lookup problem into a delivery problem.

Step 3: replace lookups with IP ranges where you can

Terms that name an IP range cost nothing. If you run your own mail server, writing ip4: with its address instead of a or mx removes a lookup and makes the record cheaper to evaluate. RFC 7208's own examples of ways to publish the same policy rank a record of plain ip4 terms as the best option and a record with an mx term as the expensive one.

That only works for addresses you control and that rarely change. For a third-party provider, see the next step.

Step 4: flatten, but know what you're signing up for

SPF flattening means replacing an include with the IP addresses it resolves to, so the record needs no lookups for that provider. It does get you under the limit. The catch is that a flattened record is a snapshot. If the provider changes its sending addresses and your record still lists the old ones, mail from that provider can start failing SPF, and nothing in your DNS panel will warn you.

Some services publish and keep flattened records current for you. If you flatten by hand, put a reminder somewhere real to re-check it, and treat it as a record you maintain rather than one you set once. The RFC's own advice is to weigh the cost of a record against its maintainability, and that is a fair summary of the trade-off.

Step 5: split mail across domains

The limit applies to each domain's SPF evaluation. That makes a separate sending domain or subdomain for different streams a clean fix when the root cause is that one domain does too many jobs. Cold outreach on its own domain, with a short record listing only the mailbox provider, never competes for lookups with your newsletter tool or your billing system.

Our cold email domain setup checklist walks through the whole sequence, SPF record included.

Step 6: drop ptr

If you find a ptr term in an old record, remove it. RFC 7208 says the mechanism should not be published. It describes it as slow, less reliable when DNS has errors and a heavy burden on the reverse-lookup name servers, and says more reliable alternatives exist. It also still counts toward your 10.

Check it again after every change

An SPF record isn't something you edit once. Each time you add a sending tool, count again. The domain health view in InboxRampUp runs live DNS checks for the domain behind each connected mailbox, covering SPF, DKIM, DMARC, MX and blacklist status, so a failing check sits right next to the mailbox it affects.

The domain health view for one mailbox, showing live SPF, DKIM, DMARC, MX and blacklist checks (demo data)
In InboxRampUp: live DNS checks for a mailbox's domain, shown with demo data.

We cover each test and how to read a failing one in the domain health check guide. Fix SPF before you start a warmup ramp on a new mailbox. Warmup builds reputation for a legitimate sender, and it can't make up for a record that returns an error.

FAQ

What is the SPF 10 DNS lookup limit?

RFC 7208 requires SPF implementations to stop at 10 DNS-triggering terms in one evaluation. The terms are include, a, mx, ptr, exists and the redirect modifier. Going past 10 returns permerror.

Do ip4 and ip6 count toward the limit?

No. The ip4, ip6 and all mechanisms and the exp modifier don't cause DNS queries at evaluation time, so they aren't counted.

Do nested includes count?

Yes. The limit is tracked as a single total across the whole evaluation, so lookups inside a provider's included record add to your count.

Is it safe to flatten my SPF record?

It can be, as long as you keep it current. A flattened record lists IP addresses as they were when you built it. If a provider changes addresses, the record goes stale, so re-check it on a schedule or use a service that keeps it updated.

Can I publish two SPF records to get more lookups?

No. A domain must not publish more than one SPF record, and a receiver that finds two returns permerror. Combine them into one record, or split the mail across different domains.

Check your SPF record today

Run your domain through the free deliverability checker to see where SPF, DKIM, DMARC, MX and blacklists stand right now. When the DNS side is sound, start the free trial with no credit card and connect a mailbox, so warmup builds on a record that works.

  • SPF
  • DNS lookups
  • email authentication
  • deliverability
  • cold email

Ready to get out of spam for good?

Build sender reputation on autopilot. Free trial, no credit card required.