2 months ago
I am currently trying to deploy my django backend.
I have added all of the env variables and settings on railway that I need including a custom domain, build and start commands, and it deploys successfully. However, it's only successful when I set my DJANGO_ALLOWED_HOSTS to * (meaning it serves any domain name).
When I limit it to the following domain names:
uwpathr-backend.up.railway.app
uwpathr-backend.railway.internal
it fails during the healthcheck and outputs "Attempt #<attempt-number> failed with service unavailable. Continuing to retry for <time>". i.e. it fails to connect to a simple health/ endpoint, which I assume means the request sent to that endpoint was rejected and didn’t go through due to ALLOWED_HOSTS.
Pinned Solution
2 months ago
This is a common issue, even i faced it. what you can do is.
Railway's internal health check mechanism often pings the application from within the container using localhostor 127.0.0.1 to ensure the process is running on the designated port.
Because you restricted Allowed_hosts to public domains only, the health check (pinging 127.0.0.1) is being rejected by Django with a 400 bad request, causing the deployment to fail.
add these to your Allowed_hosts:
.railway.app (will cover all subdomains)
127.0.0.1
localhost
and one silly issue that i faced when iput up space before my allowed hosts in env variable make sure your env variable looks like this
Allowed_Hosts=uwpathr.rocks,www.uwpathr.rocks,uwpathr-backend.up.railway.app
adding local host and writing env varible properly will most probably fix the issue
2 Replies
2 months ago
Hey there! We've found the following might help you get unblocked faster:
If you find the answer from one of these, please let us know by solving the thread!
2 months ago
This is a common issue, even i faced it. what you can do is.
Railway's internal health check mechanism often pings the application from within the container using localhostor 127.0.0.1 to ensure the process is running on the designated port.
Because you restricted Allowed_hosts to public domains only, the health check (pinging 127.0.0.1) is being rejected by Django with a 400 bad request, causing the deployment to fail.
add these to your Allowed_hosts:
.railway.app (will cover all subdomains)
127.0.0.1
localhost
and one silly issue that i faced when iput up space before my allowed hosts in env variable make sure your env variable looks like this
Allowed_Hosts=uwpathr.rocks,www.uwpathr.rocks,uwpathr-backend.up.railway.app
adding local host and writing env varible properly will most probably fix the issue
Status changed to Solved brody • about 2 months ago
