Error guide / SPF PermError: too many DNS lookups
SPF PermError from too many DNS lookups: what it means and how to fix it
SPF PermError means the SPF record cannot be evaluated at all, and by far the most common reason is the DNS lookup limit. RFC 7208 allows at most 10 DNS-querying terms per SPF evaluation: include, a, mx, ptr, exists and redirect cost one each, while ip4, ip6 and all cost nothing. Past 10 the result is a permanent error, and receivers are supposed to treat the whole record as invalid, so every sender you authorized stops counting at once. It shows up as mail from your domain being rejected or filed as spam, or as a permerror line in a message header, a DMARC aggregate report or a deliverability dashboard.
Check your site
What causes it
The limit is almost always crossed by adding vendors. Each include: for a helpdesk, a CRM or a newsletter tool costs one lookup itself plus every lookup inside that provider's policy, because the count is recursive: an include inside their include lands in your budget of 10. The second cause needs no action from you: a provider enlarges its own published policy, and a record that cost 9 lookups yesterday costs 11 today. Less often the record is padded with a: and mx: terms for servers that have fixed addresses, or with a ptr term, which costs a lookup and is deprecated.
How to fix it
- Run the check on this page for your domain and read the number it prints. It expands your SPF record, follows every include: and redirect= recursively, and reports how many DNS lookups the record costs against the limit of 10. At 10 or fewer, and without the word "partial" next to the count, the lookup limit is not the problem; look instead for two v=spf1 records on the same domain, a syntax error, or more than two lookups pointing at names that do not exist (these void lookups also give a PermError). At 11 or more, the limit is the cause, and the steps below fix it.
- Delete the includes for services you no longer send from. Write out every include: in the record and match each one to a live sender. The CRM you trialled two years ago and the hosting company you left are usually still there, and they are the cheapest lookups to win back.
- Replace terms that cost lookups with literal addresses. ip4, ip6 and all are free, so writing out the four sending ranges a provider publishes takes it from several lookups to zero; this is called flattening. An a: or mx: term for a server with a fixed address is cheaper written as ip4, and a ptr term should be removed. The downside is that hard-coded ranges go stale when a provider changes its infrastructure, and nothing warns you. Review them on a schedule, and flatten only providers that publish a stable, documented list.
- Consolidate senders. Two newsletter platforms, or a CRM that could relay through the mail provider you already authorize, cost a whole include each. Moving to one provider removes those lookups permanently.
- Move bulk mail to a subdomain. news.example.com or mail.example.com gets its own SPF record and its own budget of 10 lookups, so the marketing platform's include lives there instead of on your main domain. In the platform's settings, set the envelope sender (Return-Path) to the subdomain, because SPF is checked against that domain and not the From: header. DMARC's default relaxed alignment accepts a subdomain of your domain; strict alignment (aspf=s) does not.
- Consider an SPF flattening service only after all of the above. It resolves the includes for you and keeps a generated record current, and that works, but your mail delivery then depends on someone else's uptime and on a record you no longer read. A free tier that quietly stops updating shows up as bounced mail.
- After any edit, wait for the DNS TTL to run out and run the check again to see the new number.