7 months ago
Having some kind of issue where railway wasn't able to hit the path during the health check.
"deploy": {
"runtime": "V2",
"numReplicas": 1,
"startCommand": "npm run start",
"healthcheckPath": "/api/health/services?password=",
"preDeployCommand": [
"npm run postinstall"
],
this seems to fail with 404s
but if I remove the health check, post-deploy this curl seems to work:
curl --location 'https://[server].railway.app/api/health/services?password='
5 Replies
7 months ago
atjain03, you can check my post on the same issue: https://station.railway.com/questions/node-js-service-failing-to-deploy-with-s-dc58e402#mk2w
If that doesn't help, please provide the code for the server file till the healthcheckup endpoint, so that we can see what might be wrong!
clashing
atjain03, you can check my post on the same issue: https://station.railway.com/questions/node-js-service-failing-to-deploy-with-s-dc58e402#mk2wIf that doesn't help, please provide the code for the server file till the healthcheckup endpoint, so that we can see what might be wrong!
7 months ago
That linked post is also very helpful in setting up the health checkup endpoint in Railway. But I want to add something specifically regarding your issue:
At my end, I tried doing something similar to what you have been doing, and wrote this code:
// health checkup endpoint
app.get("/healthcheckup/:password", async (req, res) => {
console.log("Health checkup endpoint");
console.log(req.params);
if (req.params && req.params.password) {
res.status(200).json({ success: true });
} else {
console.error("Healthcheck endpoint failed! Unable to grab the password");
res.status(400).json({ success: false });
}
});This worked perfectly fine for me. My suggestions for what you can do right at your end:
a. I know the length of the endpoint doesn't matter, but it's best to keep it very minimal, like I have done /healthcheckup/:password
b. Rather than a query parameter, I embedded the pwd in the route itself, making it accessible via req.params
You cannot define an endpoint having query parameters in express!
Refer to the above-linked post to ensure that your code is 100% compliant with how Railway expects the health checkup endpoint to be defined & used.
I hope that helps you 
6 months ago
Did my reply help you? If yes, and the issue is resolved, do mark that as the solution.