Deploy fails due to it not being able to check \health endpoint
The deploys are funky when triggered by new pushes to project's master branch. Sometimes they pass the check and some other times I just have to remove the previous active deploy and redeploy but even then the behavior is unpredictable. Some other times pushing a new change helped. I'm using golang (gin).
router.Run(ip + ":" + port)
where ip is 0.0.0.0
and port is defined as a service variable on port 8080
.
My deploy details are:
buildCommand is basically: go get && go build -o main
Would love help on this since it makes fixing an urgent issue a bit of a nightmare. Thanks!22 Replies
Project ID:
ec8587ed-0fb6-417a-a80d-ab29eb6a37b6
Project ID:
ec8587ed-0fb6-417a-a80d-ab29eb6a37b6
first, why have you set a custom build command?
@Horserix ping for viability
I used that in another platform and it worked when used it after creating the project. I have no problem using the recommended settings from the docs. I just didn't think this could have an impact on the deploy due to it working a while ago
I'll try removing it and using the default and ping you back if it changes 👍
what do the healthchecks fail with?
These are the last logs from the
build logs
:
I just used the default config for the build and deploy and it seems it's having the same issues. It's stuck at the health check attempts 🤔can you show me the code that starts the server?
Sure!
The service variable
ENVIRONMENT
is correctly set as production
in the Variables tab
The /health
GET
endpoint is allowed. There were multiple past deployments where the health checks worked btw and haven't changed it sinceshow me the health endpoint code?
what is your port variable set to
8080
anything bad in the deployment logs when the healthcheck fails?
Nope, everything goes well, the build and publishing are both successful 🤔
In the deploy logs I can see the server running ok. But it's not being hit by any of the requests. I have a previous deployment that is active and working. Which it was triggered a commit ago and worked. It is weird 🤔
But the new commit just fails due to the health check
don't listen on 0.0.0.0
just do
router.Run(":" + port)
I can try that again. I was doing that previously and encountered the same issue. When this first happened I had that setup (
router.Run(":" + port)
). Which resulted in me then adding the ip
after checking the docs and the odd behavior creeped in again
btw thanks for helping out 👍let me know how that goes
Didn't work :/
Stuck at the health endpoint check again (To add a bit more context too, I tried disabling the check but obviously when I attempt to make a request to the server I get a
Application failed to respond
after its deployment).gin is misbehaving then
I have full confidence this isn't a problem with railway
Interesting, I'll try setting up just the health endpoint using somethinge else other than gin and confirm this is the case. Thanks!
sounds good
i'm having a similar issue, @Horserix did you manage to resolve it?
on my case the problem was my server expected (mandatory) a https request and Healthcheck seem to be a http request.
Allowing for http on healthcheck endpoint solved it for me.