Skip to content
SPF records fail because of CNAME to railway domain
rasmuslian
OP

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 πŸ™‚

Closed

21 Replies

rasmuslian
OP

2 years ago

N/A


dane-stevens

2 years ago

This should be possible. What DNS provider are you using?


rasmuslian
OP

2 years ago

Sorry for the late reply. I'm using Namecheap. My SPF records are not working.


dane-stevens

2 years ago

Are you using Namecheap's "Web Hosting DNS" (do you have cPanel?)



rasmuslian
OP

2 years ago

Yeah I use the "Advanced DNS"



rasmuslian
OP

2 years ago

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.


dane-stevens

2 years ago


dane-stevens

2 years ago

You'll need to delete the CNAME record first


rasmuslian
OP

2 years ago

@dane.stevens Maybe, but I'm a bit hesitant since @Brody answered like this when asked the same question:

1272863947690872832


dane-stevens

2 years ago

ANAME is essentially a CNAME without the restrictions: https://dnsmadeeasy.com/post/what-is-an-aname-record


dane-stevens

2 years ago

you can always set up a second domain on railway, and point an ANAME to that to test it


rasmuslian
OP

2 years ago

What could be disadvantages of using ALIAS record then? If @Brody answered like that, must be some disadvantage no?


dane-stevens

2 years ago

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)


rasmuslian
OP

2 years ago

Using Cloudflare NS is definately a possibility. So CNAME flattening makes other DNS records (such as SPF records) work?


dane-stevens

2 years ago

Yeah, it basically masks the CNAME as an A record


rasmuslian
OP

2 years ago

But if it masks the CNAME record will Railway still find that record then?


dane-stevens

2 years ago

Yes


rasmuslian
OP

2 years ago

Okay. Will test and see if it works.


rasmuslian
OP

2 years ago

@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 πŸ˜„


Welcome!

Sign in to your Railway account to join the conversation.

Loading...