djangosslproxyssl-certificaterailway

SSL handshake failed with host when using Cloudfare with Railway.app


When I connected a Cloudfare proxy with my Django app hosted on Railway.app, I get the error:Error Image. I bought my domain from Godaddy.

Please note that it was working fine a while ago and this problem started when I made a small bug fix in my models.py (should be unrelated) and redeployed my site.

I believe this is because I have not installed the Origin Certificate on Railway.app. On Cloudfare, my SSL/TLS encryption mode is Full. If so, how do I install this certificate on Railway.app which is my origin server.

Any help would be appreciated.


Solution

  • Fix: Delete all DNS records in Cloudfare and add the CNAME DNS record generated by Railway.app.

    Explanation: I used GoDaddy to buy my domain. You cannot connect Railway.app with GoDaddy the recommended way (CNAME), so I connected it with A and www instead of CNAME.

    When I changed the nameservers to Cloudfare, these connections of A and www remained. For some reason (maybe due to dynamic DNS update done by Railway), when the IP address for my origin server changed (the one which was used in A), Cloudfare was not able to successfully SSL handshake with the origin server.