Suped

How to fix SPF record exceeding DNS lookup limit?

Matthew Whittaker profile picture
Matthew Whittaker
Co-founder & CTO, Suped
Published 25 Jul 2025
Updated 17 Aug 2025
9 min read
Dealing with SPF records can often feel like navigating a maze, especially when you encounter the dreaded "too many DNS lookups" error. It's a common issue that can silently impact your email deliverability, leading to legitimate emails being flagged as spam or rejected outright by receiving mail servers. I've seen many instances where businesses struggle to understand why their SPF passes sometimes and fails at others, only to discover it's due to this often-overlooked limit.
The core of the problem lies in the Sender Policy Framework (SPF) specification, which mandates a maximum of 10 DNS lookups to fully evaluate an SPF record. While it might seem straightforward, this limit includes all nested lookups triggered by mechanisms like include, a, and mx. If this limit is exceeded, a PermError occurs, indicating a permanent failure that will very likely prevent your emails from reaching the inbox.
The challenge is that many modern businesses rely on multiple third-party email services for marketing, transactional emails, and customer support. Each of these services typically requires an include statement in your SPF record, and some of those include themselves contain multiple lookups. This can quickly push you over the 10-lookup threshold. Let's explore how to diagnose and effectively fix this common SPF record issue.
Suped DMARC monitoring
Free forever, no credit card required
Learn more
Trusted by teams securing millions of inboxes
Company logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logo

Understanding the SPF DNS lookup limit

SPF (Sender Policy Framework) is an email authentication method designed to prevent sender spoofing. It allows domain owners to publish a DNS TXT record listing all the IP addresses or domains authorized to send emails on their behalf. When a receiving mail server gets an email, it checks the sender's SPF record to verify if the sending server's IP address is authorized. If it's not, the email might be rejected or marked as spam.
The crucial detail is that the SPF specification, outlined in RFC 7208, explicitly limits the number of DNS lookups to 10. This limit is in place to prevent denial-of-service attacks and reduce the load on DNS servers. Each time your SPF record uses mechanisms like a, mx, ptr, exists, or include, it triggers a DNS lookup. The problem intensifies because an include statement may itself resolve to another SPF record that also performs DNS lookups, creating a chain of lookups that quickly adds up.
This means even if your SPF record explicitly lists only a few include statements, the total number of DNS queries could easily exceed 10 if those included domains also have complex SPF records. This is why understanding how important the 10 DNS lookup limit is, is critical for maintaining good email deliverability.

Diagnosing an SPF lookup limit issue

The first step to fixing this issue is to accurately diagnose it. Many users are surprised to find they are over the limit, even with seemingly short SPF records. The key is to check not just your direct record, but also the SPF records of any domains you've included. This recursive checking is what quickly adds up. For example, if you include include:thirdparty.com, and thirdparty.com itself includes three other domains, that single entry in your SPF record counts as four lookups towards your limit.
Common culprits for exceeding the limit are widely used email service providers like Mailchimp, SendGrid, HubSpot, and Zendesk. While their direct SPF includes might seem minimal, their own SPF records often contain numerous nested lookups for various sub-services or IP ranges. If you're using several such providers, even a few include statements can quickly push you past the 10-lookup barrier.
To identify if your SPF record is exceeding the limit, you can use an SPF lookup tool. These tools will parse your SPF record and recursively check all included domains, providing you with an accurate count of DNS lookups. Here’s an example of an SPF record that might lead to too many lookups:
Example SPF record
v=spf1 include:servers.mcsv.net include:_spf.google.com include:u17646292.wl043.sendgrid.net include:sendgrid.net include:mail.zendesk.com include:21904666.spf02.hubspotemail.net ~all
In the example above, even though there are only six direct include statements, some of those domains, like sendgrid.net or hubspotemail.net, have multiple nested lookups of their own. This causes the total count to exceed the limit, resulting in an SPF PermError. Being aware of how broken SPF records affect deliverability is the first step toward a solution.

Strategies to reduce SPF DNS lookups

Once you've identified that you're hitting the SPF DNS lookup limit, there are several strategies you can employ to bring your record back into compliance. The simplest first step is to review your SPF record and remove any unnecessary or outdated mechanisms. For instance, if you previously used an email service but no longer do, its include statement can be safely removed. I often find that clients have old entries for services they stopped using years ago. This quick audit can often free up several lookups.
Another effective method is to replace include statements with direct IP addresses where possible, using ip4 or ip6 mechanisms. This avoids DNS lookups entirely for those specific entries. However, this approach is only viable if the IPs of your sending services are static and do not change frequently. If they are dynamic, you would need to constantly update your SPF record, which is rarely practical. This is a crucial consideration when deciding how SPF 'a' records affect DNS lookups and the overall limit.
A more advanced and commonly recommended solution is SPF flattening. This technique involves taking all the include mechanisms in your SPF record, resolving them to their current IP addresses, and then listing those IP addresses directly in your record. While it effectively bypasses the lookup limit, it introduces a new challenge: managing DNS TXT record length limits, and requires regular updates if the service's IPs change. Many service providers dynamically adjust their IP ranges, so manual flattening can become a maintenance burden. This is one of the options for dealing with overstuffed SPF records.

Standard SPF setup

This involves adding include statements for each email service provider directly to your main domain's SPF record. It's simple to set up initially.

Pros

  1. Simplicity: Easy to add new services by just adding an include.
  2. Maintenance: Updates to IP addresses are handled by the service provider, not you.

Cons

  1. Lookup Limit: Very susceptible to exceeding the 10 DNS lookup limit due to nested lookups.
  2. Deliverability: Frequent SPF PermErrors lead to email rejection or spam flagging.

SPF flattening / Subdomains

SPF flattening converts all include statements into IP addresses. Alternatively, using separate subdomains for different sending services allows each subdomain to have its own SPF record.

Pros

  1. Compliance: Effectively bypasses the 10 DNS lookup limit.
  2. Deliverability: Significantly improves email deliverability by ensuring SPF passes consistently.

Cons

  1. Maintenance: SPF flattening requires frequent updates if service IPs change. Subdomains add complexity to DNS management.
  2. Complexity: Can be more complex to set up and manage initially.

Advanced solutions and best practices

For organizations using multiple email sending services, one of the most robust ways to address the DNS lookup limit is to utilize subdomains. Instead of cramming all include statements into your root domain's SPF record, you can create separate subdomains for different types of email traffic. For example, marketing.yourdomain.com could have an SPF record for your marketing platform, while transact.yourdomain.com handles transactional emails. This effectively gives each subdomain its own 10-lookup budget, significantly expanding your SPF capacity. This helps to optimize your SPF record for multiple sending services.
Another strategy is to consolidate your email sending through fewer providers where feasible. While this isn't always possible, especially for larger organizations, streamlining your email infrastructure can naturally reduce the number of SPF include statements required. Always consult your email service provider's documentation on SPF, as some offer CNAME-based authentication options that effectively delegate the SPF lookup to their domain, thereby not counting against your 10-lookup limit. For example, SendGrid provides such a method for domain authentication.
Beyond initial fixes, consistent monitoring and auditing of your SPF records are crucial. As your email infrastructure evolves, new services are added or old ones removed, your SPF record needs to keep pace. Leveraging DMARC reports can provide valuable insights into SPF authentication failures, helping you pinpoint exactly where issues are arising and address them proactively. This proactive approach ensures your emails continue to reach their intended recipients without hitting a blocklist (or blacklist).

SPF health checklist

  1. Audit regularly: Periodically review your SPF record to remove unused services. This helps in how to format SPF TXT records and avoid DNS size issues.
  2. Check nested lookups: Use an SPF lookup tool to get the true lookup count, accounting for all recursive lookups.
  3. Consider subdomains: Employ subdomains for different email sending purposes to distribute SPF lookups.
  4. Leverage DMARC: Use DMARC reports to monitor SPF authentication results and identify failures.
  5. Explore CNAME options: Check if your ESPs offer CNAME-based domain authentication to offload SPF lookups.

Views from the trenches

Best practices
Regularly audit your SPF record to remove outdated or unused services.
Implement DMARC to gain visibility into SPF authentication failures.
Use subdomains to segregate email sending for different services.
Common pitfalls
Assuming the 10-lookup limit only applies to top-level include statements.
Neglecting to check for nested DNS lookups within included SPF records.
Not removing old email service providers from your SPF record after migration.
Expert tips
Consider SPF flattening for domains with highly dynamic IP ranges if direct IP inclusion is not feasible.
Leverage DMARC reports to identify specific services causing SPF lookup failures.
For large organizations, centralize SPF record management to prevent sprawl.
Marketer view
Marketer from Email Geeks says: It's surprising how quickly the SPF lookup limit can be exceeded even with a small number of direct includes. Nested lookups within included domains often cause this issue.
Dec 13, 2023 - Email Geeks
Marketer view
Marketer from Email Geeks says: One of the challenges is that an included ESP's SPF record might itself contain many lookups, which all count towards your domain's limit.
Dec 13, 2023 - Email Geeks

Ensuring SPF record compliance for robust email delivery

Effectively managing your SPF record to stay within the 10 DNS lookup limit is a critical component of robust email deliverability and security. By understanding how recursive lookups work, diligently auditing your record, and implementing strategies like subdomain segmentation or SPF flattening, you can avoid common SPF PermErrors and ensure your legitimate emails consistently reach the inbox. It's an ongoing process, but one that pays dividends in improved email performance and brand trust.

Frequently asked questions

DMARC monitoring

Start monitoring your DMARC reports today

Suped DMARC platform dashboard

What you'll get with Suped

Real-time DMARC report monitoring and analysis
Automated alerts for authentication failures
Clear recommendations to improve email deliverability
Protection against phishing and domain spoofing