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

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

  1. Remove includes you don't use any more: old newsletter tools, a CRM you trialled, a helpdesk you replaced.
  2. Remove duplicates. include:spf.protection.outlook.com listed twice, or mx plus the provider's include for the same servers.
  3. Move senders to subdomains. Marketing mail from news.yourdomain.com gets its own SPF record and its own 10 lookups. Most email marketing tools support a custom sending subdomain.
  4. 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.