2 years ago
Hi, I have a website hosted at Railway via CNAME (as is the only option provided). Now I realized that it is not possible to have CNAME and at the same time have SPF TXT records for the same domain. SPF checks for emails fail because of this. Are there any workarounds?
Thank you in advance 🙂
21 Replies
Sorry for the late reply. I'm using Namecheap. My SPF records are not working.
I have no issue adding SPF record, I have done that and it worked before I attached the CNAME record to Railway. However, the DNS spec states that, "if a CNAME record is present, no other data should be present" (https://serverfault.com/questions/834320/adding-both-cname-and-txt-dns-records-for-one-subdomain).
Because of this, my emails fail the SPF check while the CNAME is active.
Try changing your CNAME to an ALIAS Record (ANAME): https://www.namecheap.com/support/knowledgebase/article.aspx/10128/2237/how-to-create-an-alias-record/
@dane.stevens Maybe, but I'm a bit hesitant since @Brody answered like this when asked the same question:

ANAME is essentially a CNAME without the restrictions: https://dnsmadeeasy.com/post/what-is-an-aname-record
you can always set up a second domain on railway, and point an ANAME to that to test it
What could be disadvantages of using ALIAS record then? If @Brody answered like that, must be some disadvantage no?
It's possible railway is checking specifically for CNAME and doesn't support ANAME. If they don't, you may want to re-point your NS servers to cloudflare (Cloudflare does something called CNAME flattening which negates this issue)
Using Cloudflare NS is definately a possibility. So CNAME flattening makes other DNS records (such as SPF records) work?
But if it masks the CNAME record will Railway still find that record then?
@dane.stevens Actually tried the ALIAS record method first (as it was easiest to test), and everything seems to be working very fine. Both Railway domain and SPF-records works perfectly according to my testing. Will stick with that, @Brody please intervene if me and @dane.stevens missed something about why ALIAS might be suboptimal. Thanks for your help @dane.stevens 😄