Guide
Fix “SPF permerror: too many DNS lookups”
Why SPF stops at 10 lookups, how to count yours, and four ways to get under the limit.
Updated
If a mail server reports SPF permerror or “too many DNS lookups”, your SPF record needs
more than 10 DNS queries to evaluate. The SPF standard (RFC 7208) caps a check at 10, and a receiver
that hits the cap stops and treats SPF as failed, for every message, including mail from servers you
did list. With DMARC in place, that can push legitimate mail to spam or get it rejected.
What counts as a lookup
| Term | Counts? |
|---|---|
include: | 1, plus everything inside the included record |
a, mx | 1 each |
exists:, ptr | 1 each |
redirect= | 1, plus the target record |
ip4:, ip6:, all | 0 |
The catch is nesting. include:_spf.google.com looks like one lookup, but Google’s record
has included further records of its own in the past, and every one counts. Providers change their
records without telling you, so a record that was at 9 can reach 11 on its own. There is a second,
smaller limit too: no more than 2 lookups that return nothing (“void” lookups), such as an include
of a domain with no SPF record.
Count yours
Run the SPF checker. It follows every include and redirect, shows the whole tree, and adds up the lookups. Anything at 8 or more is worth fixing now, while it still works.
Four ways to get under 10
1. Remove what you don’t use
The most common cause is history: an include for a newsletter tool you left years ago, a CRM trial, an old helpdesk. Ask each team what actually sends mail today, and delete the includes nobody claims. DMARC reports show which sources really send as you, so you can check before you remove anything.
2. Replace a and mx with IP addresses
a and mx each cost a lookup to find addresses you could write down. If
your web server or mail server sends mail from a fixed address, replace them with ip4: (and ip6:) entries, which cost nothing. If your MX records point
at Google or Microsoft, mx is usually redundant with their include anyway.
3. Move bulk mail to a subdomain
Each domain gets its own 10 lookups. Send newsletters from news.example.com and
transactional mail from mail.example.com, each with an SPF record listing only its
own service. As a bonus, a reputation problem with the newsletter doesn’t touch your staff’s
mail. Many services also send from their own return-path domain once you set up a custom domain
with them, and then need no include in your root record at all; check their setup pages.
4. Flatten, carefully
“Flattening” replaces includes with the IP ranges they currently resolve to, so they cost nothing. It works, but providers change their ranges, and a flattened record silently goes out of date and starts failing for new servers. Only flatten with a tool or service that re-checks the ranges and updates your record automatically, and never flatten the big mailbox providers by hand.
Things that don’t help
- A second SPF record. Two records is a permerror in itself. Everything has to be in one.
- Splitting into two TXT strings. Long records are split into strings of 255 characters, but they’re joined back into one record before checking; the lookup count is the same.
- Changing
~allto?all. The limit is hit before “all” is reached, so the ending makes no difference.
Related tools
All toolsSPF Record Checker
Validate an SPF record, follow every include and count DNS lookups against the limit of 10.
DMARC Record Checker
Read a domain’s DMARC policy in plain words and see what to change before tightening it.
Email Domain Health Check
SPF, DKIM, DMARC and MX checked together, with a score and a list of fixes.
More guides
- SPF, DKIM and DMARC explained What each record does, how they work together, and the order to set them up in.
- Gmail, Yahoo and Microsoft sender requirements What the big mailbox providers require of senders, and how to check you meet it.
- Moving DMARC from p=none to p=reject A safe, step-by-step path to full DMARC enforcement without losing legitimate mail.