11 days ago
Hello,
My Node.js application is stuck in a deployment loop and consistently fails with a SIGTERM
error, indicating a health check timeout. I have already taken all the standard steps to resolve this, but the issue persists.
Here is what I have already done:
The backend is a standard Node.js/Express app with a PostgreSQL database.
The
Start Command
andRoot Directory
(./backend
) are set correctly.I refactored my
server.js
to start the Express server immediately and initialize the database connection after the server is listening, specifically to pass the health check.I have even added a dedicated
/health
endpoint and configured it in the service settings.All environment variables, including
DATABASE_URL
andGOOGLE_CREDENTIALS
, have been meticulously verified.I have deleted and recreated the service multiple times, but the
SIGTERM
error continues on every new deployment.
The application runs perfectly, but it seems to be failing to become healthy in the Railway environment. Could you please check the internal platform logs for my service to see why it is being terminated?
Project Name:superb-light
Service Name:exemplary-appreciation
Thank you.
8 Replies
11 days 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!
10 days ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open brody • 10 days ago
10 days ago
Hi @vishrut28, most probably in your server file, you might have declared a pre-configured port number, which Railway addresses as Magic/Target Ports. If this is the case, then you have to follow these steps:
a. Before deploying the service, add the PORT variable and use the port number that you are using in the server file.
b. In the healthcheck path setting, you can use /health or health (or whatever endpoint that you are using to do the healthcheck). The slash is not important
I did that on my Express server, and it was a success
The endpoint for your reference is:
app.get("/health", async (req, res) => {
res.status(200).send({
success: true,
});
});
Furthermore, you can refer to this doc: https://docs.railway.com/guides/healthchecks#configure-the-healthcheck-port
clashing
Hi @vishrut28, most probably in your server file, you might have declared a pre-configured port number, which Railway addresses as Magic/Target Ports. If this is the case, then you have to follow these steps:a. Before deploying the service, add the PORT variable and use the port number that you are using in the server file.b. In the healthcheck path setting, you can use /health or health (or whatever endpoint that you are using to do the healthcheck). The slash is not importantI did that on my Express server, and it was a successThe endpoint for your reference is:app.get("/health", async (req, res) => { res.status(200).send({ success: true, }); });Furthermore, you can refer to this doc: https://docs.railway.com/guides/healthchecks#configure-the-healthcheck-port
10 days ago
Your current build-logs might be looking like this:
This is because of the fact that the PORT is not added as a variable for the Target Port
Do let me know, if you face any other issue
clashing
Your current build-logs might be looking like this:This is because of the fact that the PORT is not added as a variable for the Target PortDo let me know, if you face any other issue
10 days ago
Thanks mate for the help!
The thing is, i tried this way, but still getting the same old error
vishrut28
Thanks mate for the help!The thing is, i tried this way, but still getting the same old error
10 days ago
Can you please post the screenshot of build-logs, and one for your PORT environment variable, along with your app.listen code from express file.
Btw, we can also use "/" as the healthcheckup endpoint.
clashing
Can you please post the screenshot of build-logs, and one for your PORT environment variable, along with your app.listen code from express file. Btw, we can also use "/" as the healthcheckup endpoint.
10 days ago
And also please provide the healthcheckup endpoint that you are using. Surely, we will resolve the issue
9 days ago
Any update, @vishrut28?
You can also check your healthcheckup timeout constant, by default it is 300seconds, if your healthcheckup endpoint do not return 200, then it fails, and send SIGKILL, which is exactly what is happening with you.
Can you please provide the screenshots that I asked earlier?
5 days ago
Any update, @vishrut28?