Blog

SPF Too Many DNS Lookups: Fix the PermError

Trace nested SPF lookups, explain why one sender passes while another fails, and choose a repair that preserves legitimate mail and domain authorization.

To fix an SPF “too many DNS lookups” error, trace the complete authorization path, including nested provider records, then remove unnecessary dependencies or separate supported sending services onto their own subdomains. Adding another SPF record or relaxing the final failure setting does not increase the limit.

For the email administrator onboarding a new billing or marketing service, the confusing symptom is that ordinary employee mail still passes while the new service returns permerror. Different senders can take different paths through the same record. That makes the sending system—not just the domain name—the starting point for diagnosis.

What the SPF lookup limit actually counts

Sender Policy Framework (SPF) uses the Domain Name System (DNS) to publish which servers may send for an email envelope domain. The envelope sender used during delivery can differ from the From address a recipient sees. Start with the domain the receiving system actually checked.

RFC 7208 limits SPF evaluation to ten DNS-querying terms: include, a, mx, ptr, exists, and redirect. Exceeding that limit produces permerror, a permanent evaluation error. Nested terms count, so three provider entries can require more than ten lookups.

ip4, ip6, and all do not consume that budget. Other evaluation errors are possible; retain the receiver's diagnostic to confirm the lookup limit is the cause.

Follow the sender that reaches the eleventh term

Consider Harbor Office Supply, a hypothetical distributor. Its email administrator, Lena, adds a new invoice service after its staff-mail and old campaign-service entries in the SPF record. All three use the same envelope domain in this example. The following counts are illustrative assumptions, not measurements of real providers.

For a message from the new invoice service, assume the first two services do not match, all referenced records are otherwise valid, and the matching authorization would be reached only at the end of this sequence:

  1. Staff-mail entry: its outer include and two nested includes consume three terms. No match; the running count is three.
  2. Old campaign entry: its outer include and three nested includes consume four more. No match; the running count is seven.
  3. Invoice-service entry: reaching its matching authorization would consume another four terms. That would require eleven in total, so evaluation stops with permerror before reaching the match.

An employee message can match within the first branch and finish successfully. Microsoft's SPF configuration guidance explains this early-stop behavior and nested lookup counting. Merely moving invoices to the front could move the failure to another sender. Reordering alone leaves the long evaluation path in place.

Her useful support record identifies the failed sending service, checked envelope domain, receiving system's result, and the expanded path. Network Box USA's Managed Cloud Email Security service includes sender and message filtering, spoofing controls, reporting, and operational support, with mail-flow and policy validation during deployment. That managed work helps coordinate investigation on the subscribed mail route while retaining message protection. DNS changes and third-party sender configuration remain with their responsible owners unless separately agreed.

Remove obsolete senders before adding complexity

Google's SPF troubleshooting guidance recommends removing duplicate mechanisms and third parties that no longer send for the domain. Confirm retirement with the business owner first: a seasonal campaign or infrequent payroll notification may not appear in a short observation window.

Suppose Harbor's marketing owner confirms that the old campaign service has been retired, including its scheduled jobs. Lena removes that authorization through the approved DNS change process. The invoice path now requires three plus four terms: seven. She retests staff mail and invoices, then records the retired service and the reason for its removal. The repair both restores the intended evaluation and removes an unused permission.

If every service is still needed, consider separating an appropriate mail stream onto a supported subdomain with its own SPF record. Microsoft recommends this approach for third-party sending services. Confirm the provider's custom envelope-domain configuration and the message's authentication alignment; publishing a record at a new DNS name alone does not move the sender there.

Replacing provider includes with explicit IP addresses—often called flattening—creates ongoing maintenance work. Microsoft's guidance limits this approach to suitable services with stable, documented addresses and warns against flattening Microsoft 365's changing infrastructure. Do not turn a current DNS snapshot into a permanent authorization list without an owner for changes.

Keep the repair separate from delivery policy

Publish one SPF record for each checked domain. A second SPF record creates another evaluation error. Changing -all to ~all does not repair an error reached earlier in evaluation; using +all would authorize any sender that reaches it. Correct the lookup path rather than broadening authorization.

Also check DomainKeys Identified Mail (DKIM) signing and Domain-based Message Authentication, Reporting, and Conformance (DMARC). Under the current DMARC specification, a valid, aligned DKIM signature can satisfy DMARC even when SPF does not pass. Conversely, repairing SPF does not guarantee inbox delivery: the receiver still applies its other controls. Our DMARC forwarding explanation addresses the separate case where an intermediary changes the delivery path.

After the DNS change has propagated, send harmless messages from each required service to controlled recipients and inspect the trusted receiving system's authentication results. Recheck the expanded records when adding or retiring a provider. To discuss recurring delivery failures alongside managed email protection, contact our team with the affected sender, domain, and diagnostic summary. Arrange sensitive message evidence through an agreed secure channel.