SPF record too long: the 255-character limit

A single TXT string holds 255 characters. How to split a long SPF record correctly, and why shorter is still better.

DNS stores TXT records as one or more strings, each at most 255 characters. Many DNS panels refuse a longer value, or silently cut it off, which breaks the record.

How to publish a long record

Split it into several quoted strings inside one record. Receivers join them without adding anything in between:

example.com. TXT ( "v=spf1 ip4:203.0.113.0/24 ip4:198.51.100.0/24 include:_spf.google.com "
                   "include:spf.protection.outlook.com include:servers.mcsv.net ~all" )
  • Put the space inside one of the strings, at the split. Otherwise two mechanisms are glued together, like _spf.google.cominclude:, which is a syntax error.
  • It must stay one record. Two separate TXT records starting with v=spf1 are a permanent error.
  • Many DNS panels (Cloudflare, Route 53 and others) split long values automatically. Check the result with dig TXT example.com.

Shorter is better anyway

DNS answers larger than 512 bytes may need to be retried over TCP, and some resolvers and firewalls handle that badly, which leads to temporary SPF errors. A long record is often a sign of includes that are no longer needed or of a flattened record that will go stale. Before splitting, see whether you can trim it: remove old services, and move bulk senders to a subdomain.