10 months ago
I've just tried adding a healthcheck to my service - I've added an endpoint (/_ready at the moment but have tried /health as well) that returns a 200 response if I visit it in a browser or using curl, but when I redeploy with the healthcheck enabled I get:
Attempt #1 failed with service unavailable. Continuing to retry for 4m49s
until the deployment fails. I added logging to the healthcheck endpoint and I didn't see those logs in the deploy logs so it looks like the endpoint is not being hit at all. I don't think I've messed up the configuration on my end, but I can't work out what else I could change to get this working.
4 Replies
10 months ago
Railway might not know what port to make the internal health check request since you are using target ports, can you try setting a PORT
variable to 3000
in your service settings.
Status changed to Awaiting User Response railway[bot] • 10 months ago
10 months ago
Great - that worked thank you. It might be worth updating the docs to explain that - I would have assumed it would use the same detection as the HTTP proxy. Also in the docs it says "As long as you have not defined a PORT
variable, Railway will provide and expose one for you." (https://docs.railway.app/guides/public-networking#port-variable) so that's a little unclear.
Status changed to Awaiting Railway Response railway[bot] • 10 months ago
10 months ago
Glad that worked ! I've taken a note to see how we can make that bit clearer in our documentation, thanks for pointing it out!
Status changed to Awaiting User Response railway[bot] • 10 months ago
Status changed to Solved chandrika • 10 months ago
Status changed to Open brody • 10 months ago
10 months ago
Just here to update you on the docs improvements, we now have this docs section that covers your question -
https://docs.railway.app/guides/healthchecks-and-restarts#configure-healthcheck-port
Status changed to Solved brody • 10 months ago