Failing healthchecks
My healthchecks are failing and I can't quite figure out why. They work locally and there is no errors in the logs, the service appears to start properly.
32 Replies
Project ID:
fd3c34f8-2314-4d8d-8f79-2ed37386c50d
fd3c34f8-2314-4d8d-8f79-2ed37386c50d
what's your healthcheck set to?
"/health"
can you show me the code that handles that path
I have log output for those two variables, I can confirm they are both true
The healthcheck is failing with service unavailable, not 503
looks good so far
show me your app.listen code please
app.listen(process.env['PORT'] ? process.env['PORT'] : 80);
never seen it done like that before
just do
process.env.PORT || 8080
I've changed the fallback port to 8080 for when you do local development, it's always best to listen on a non privileged portI've modified it to
to match with fastify's current method signature
I'll let you know what the outcome is once the deploy is finished building
any reason you choose to go against what I said and use
['PORT']
instead of .PORT
?Oh I missed that part
Should be equivalent though
I wouldn't know, I'm not a js dev
Just to make sure, I've modified it to match the suggested signature
looks good
Still the same, service unavailable
remove the healthcheck and see what happens, once it redoploys wait a good 60 seconds before hitting the railway domain
I've figured it out
do tell
Seems like the default behaviour changed since my last deploy, without specifying the host as 0.0.0.0 it will listen to localhost only
that should not be a problem what so ever
for fastify localhost means listen on both ipv4 and ipv6 interfaces
That will make it listen to 127.0.0.1 and ::1
according to that chart, that shouldn't be a problem but I guess that's just node for you
There is some docker shenanigans here too
but healthchecks work?
Solution
I've specified the host as 0.0.0.0 now
Which restored everything
do you think it would be worthwhile for me to pr another code snippet for fastify to https://docs.railway.app/troubleshoot/fixing-common-errors
I think it might be worthwhile if only for the odd syntax that fastify uses
noted
have a nice day/night!
You too! Thanks for the help