R
Railway•4mo ago
Rasmus Lian

SPF records fail because of CNAME to railway domain

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
Percy
Percy•4mo ago
Project ID: N/A
Rasmus Lian
Rasmus LianOP•4mo ago
N/A
Dane
Dane•4mo ago
This should be possible. What DNS provider are you using?
Rasmus Lian
Rasmus LianOP•4mo ago
Sorry for the late reply. I'm using Namecheap. My SPF records are not working.
Dane
Dane•4mo ago
Are you using Namecheap's "Web Hosting DNS" (do you have cPanel?)
Rasmus Lian
Rasmus LianOP•4mo ago
Yeah I use the "Advanced DNS"
Dane
Dane•4mo ago
EasyDMARC
How to Add SPF Record in Namecheap
An SPF protocol can increase your trustworthiness in receiving email servers. Here is a step-by-step guide on how to add your SPF record in Namecheap.
Rasmus Lian
Rasmus LianOP•4mo 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.
Server Fault
Adding both CNAME and TXT DNS records for one subdomain
I have a Heroku app and I need to set up a domain for it. The common way to set it up is to use CNAME record to specify that this domain is an alias to <your-domain-name>.herokuapp.com. The t...
Dane
Dane•4mo ago
You'll need to delete the CNAME record first
Rasmus Lian
Rasmus LianOP•4mo ago
@dane.stevens Maybe, but I'm a bit hesitant since @Brody answered like this when asked the same question:
No description
Dane
Dane•4mo ago
ANAME is essentially a CNAME without the restrictions: https://dnsmadeeasy.com/post/what-is-an-aname-record
What is an ANAME Record? - DNS Made Easy Blog
ANAME record is a record that performs like a CNAME record but can be pointed at the root of a domain. Example: A record that’s been morphed into a CNAME.
Dane
Dane•4mo ago
you can always set up a second domain on railway, and point an ANAME to that to test it
Rasmus Lian
Rasmus LianOP•4mo ago
What could be disadvantages of using ALIAS record then? If @Brody answered like that, must be some disadvantage no?
Dane
Dane•4mo 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)
Rasmus Lian
Rasmus LianOP•4mo ago
Using Cloudflare NS is definately a possibility. So CNAME flattening makes other DNS records (such as SPF records) work?
Dane
Dane•4mo ago
Yeah, it basically masks the CNAME as an A record
Rasmus Lian
Rasmus LianOP•4mo ago
But if it masks the CNAME record will Railway still find that record then?
Dane
Dane•4mo ago
Yes
Rasmus Lian
Rasmus LianOP•4mo ago
Okay. Will test and see if it works. @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 😄
Want results from more Discord servers?
Add your server