SPF "too many DNS lookups": how to find the cause and fix it
SPF lets a receiving server make at most 10 DNS lookups while it evaluates your record (RFC 7208, section 4.6.4). If yours needs more, the result is permerror. Most receivers treat that as an SPF failure, and under DMARC a message that fails SPF and has no aligned DKIM signature can go to spam or be rejected.
What counts
include:,a,mx,ptr,exists:andredirect=each count as one lookup.- Lookups inside included records count too.
include:sendgrid.netcosts 2, because SendGrid's record includes another. ip4:,ip6:andallcost nothing.- Separately, at most 2 "void" lookups (names that return nothing) are allowed.
Find the cause
curl -O https://raw.githubusercontent.com/truone01/spf-lookup-check/main/spf-check.mjs node spf-check.mjs yourdomain.com
The free checker prints the total and a tree showing which include uses how many lookups.
Fix it
- Remove includes you don't use any more: old newsletter tools, a CRM you trialled, a helpdesk you replaced.
- Remove duplicates.
include:spf.protection.outlook.comlisted twice, ormxplus the provider's include for the same servers. - Move senders to subdomains. Marketing mail from
news.yourdomain.comgets its own SPF record and its own 10 lookups. Most email marketing tools support a custom sending subdomain. - Flatten. Replace includes with the IP ranges they resolve to. This works immediately, but the list goes stale when a provider changes its ranges. See SPF flattening: what can go wrong.
No command line handy? Use the online SPF lookup checker: same checks, in the browser.