Skip to content
// guide · 5 min read

SPF “too many DNS lookups” (PermError): what it means and how to fix it

Why SPF stops at ten DNS lookups, what counts towards the limit, and safe ways to fix a PermError without breaking the email services you rely on.

Published

// short answer

SPF allows at most ten DNS lookups while checking a message. Each include, a, mx, ptr, exists and redirect counts, including those nested inside your providers' includes. Go over and SPF returns a PermError and fails. Fix it by removing services you no longer use first.

You add a new email tool, paste its SPF line into your DNS, and a week later someone tells you your SPF record shows "PermError: too many DNS lookups". Nothing looked wrong. Your mail mostly still arrives. So what broke?

This guide explains the ten-lookup limit in plain English, how to count your own lookups, and the safe ways to get back under it.

What the error means

SPF is a TXT record that lists which servers may send email for your domain. When a mail provider receives a message from you, it reads that record and follows it to work out whether the sending server is allowed.

Following the record means doing DNS lookups. To stop one domain's record from making receivers do unlimited work, the SPF standard (RFC 7208) sets a hard limit: no more than ten lookups while evaluating a record. If a record needs more, the result is a PermError, a permanent error. The receiver stops and treats SPF as failed.

What counts towards the ten

What counts towards the SPF ten-lookup limit
MechanismCounts as a lookup?Notes
include:YesAnd every lookup inside the included record counts too
`a` / `a:`YesLooks up the A/AAAA records of a name
`mx` / `mx:`YesPlus the addresses of each mail server it finds
exists:YesRarely used by small businesses
redirect=YesHands evaluation to another domain's record
ptrYesDeprecated; remove it if you see it
`ip4:` / `ip6:`NoPlain addresses cost nothing
allNoThe ending, such as `-all` or `~all`

The catch is the first row. Your record might show only four include: entries, but each provider's own record can contain includes of its own. One large mailbox or marketing provider can use three or four lookups by itself. Four providers can quietly add up to eleven.

There is also a second, lesser-known limit: no more than two "void" lookups, meaning lookups that return no answer. An include: for a service you have cancelled, whose record no longer exists, can trigger that one.

How to count your lookups

  1. Look up your SPF record. Our free SPF checker shows it and counts the lookups at the top level of your record.
  2. For each include:, look up that domain's TXT record and count its lookups, then repeat for any includes inside it.
  3. Add one for each a, mx, exists and redirect you find along the way.

Our checker's count is a minimum, because it deliberately doesn't follow every include down the chain. If it already shows eight or more, you are close to the limit or over it.

Safe ways to fix it, in order

1. Remove services you no longer use

This is the fix that is right most often. SPF records collect old entries: a newsletter tool you left two years ago, a previous host, a trial you never cancelled. Each one costs lookups and is a sender you no longer need to trust. Remove anything you can't name a current use for.

2. Replace a and mx where safe

Many records include a and mx out of habit. If your website server doesn't send email, a isn't needed. If your mailbox provider is already listed with an include:, mx is usually redundant. Removing them saves lookups at no cost.

3. Move some senders to a subdomain

Marketing and bulk email tools often support sending from a subdomain such as news.yourbusiness.co.za. That subdomain gets its own SPF record with its own ten-lookup budget, and it keeps your main domain's reputation separate from your newsletters.

4. Flatten, carefully

"Flattening" replaces include: entries with the ip4: and ip6: addresses they currently resolve to. Because addresses don't count as lookups, the problem goes away. The risk is that providers change their addresses, sometimes without notice. A flattened record that nobody updates will eventually start failing your genuine mail. Only flatten with a process that keeps it up to date.

// free, passive, 30 seconds

Check your SPF record and lookup count

Run the free check

Mistakes that make it worse

  • Adding a second SPF record. It feels tidier to give the new service its own record, but two v=spf1 records on one domain is its own PermError. Always merge into one.
  • Switching to +all to "make it pass". That tells the world anyone may send as you, which defeats the point.
  • Splitting a long record over two TXT records. A single SPF record can be made of several quoted strings inside one TXT record, but not split across two separate records.

How SPF fits with DKIM and DMARC

SPF on its own can't stop someone faking the "From" address your customers see. That is DMARC's job, using SPF and DKIM together. Once SPF is back under the limit, check that DMARC is doing its part with the DMARC checker, and read DMARC p=none vs quarantine vs reject to choose the right policy.

Want it fixed for you?

Untangling an SPF record means knowing which services you actually use, which is often the hard part for a small business. Odesstra can review the record with you, remove what's unused, restructure what's left and recheck it. See website security fixes, or talk to a human first.

Questions

What happens to my email when SPF has a PermError?

Receivers treat SPF as failed for your domain. Mail can still pass DMARC if DKIM passes and matches your domain, but anything that relied on SPF alone may land in spam or be rejected.

Does ip4: count towards the ten lookups?

No. ip4: and ip6: entries are not lookups, and neither is all. Only include, a, mx, ptr, exists and redirect count.

Is SPF flattening safe?

It works, but it swaps a lookup for a fixed list of addresses that your providers can change without telling you. If you flatten, use a process that keeps the list up to date, or you will eventually block your own mail.

Can I just create a second SPF record?

No. Two v=spf1 records on one domain is its own PermError. Merge everything into one record.

Talk to a human