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
| Mechanism | Counts as a lookup? | Notes |
|---|---|---|
include: | Yes | And every lookup inside the included record counts too |
| `a` / `a:` | Yes | Looks up the A/AAAA records of a name |
| `mx` / `mx:` | Yes | Plus the addresses of each mail server it finds |
exists: | Yes | Rarely used by small businesses |
redirect= | Yes | Hands evaluation to another domain's record |
ptr | Yes | Deprecated; remove it if you see it |
| `ip4:` / `ip6:` | No | Plain addresses cost nothing |
all | No | The 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
- Look up your SPF record. Our free SPF checker shows it and counts the lookups at the top level of your record.
- For each
include:, look up that domain's TXT record and count its lookups, then repeat for any includes inside it. - Add one for each
a,mx,existsandredirectyou 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
Mistakes that make it worse
- Adding a second SPF record. It feels tidier to give the new service its own record, but two
v=spf1records on one domain is its own PermError. Always merge into one. - Switching to
+allto "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.