Container repeatedly terminated 3-5 seconds after passing health check
ddingers
HOBBYOP

4 months ago

Project ID: 3d9f21fd-de1a-4911-b263-ca661d36dcc6

My Node.js backend service (ViewSurge) is experiencing a critical issue where the container is being forcefully terminated by Railway 3-5 seconds after successfully passing the health check.

Issue Pattern:

Container starts successfully

Database connects successfully

Express server starts on port 3000

Health check at /health passes (I see [1/1] Healthcheck succeeded!)

Container is terminated with SIGTERM approximately 3-5 seconds later

Example from logs:

2026-02-02T01:15:52.411Z ✅ Database connected successfully

2026-02-02T01:15:53.374Z [EXPRESS] GET /health

2026-02-02T01:15:56.000Z Stopping Container ← Only 3 seconds after health check!

2026-02-02T01:16:04.297Z npm error signal SIGTERM

What I've already verified:

I am on a paid plan with available credits (not free tier)

The application runs perfectly locally

There are no application errors or crashes - the server is healthy when terminated

I've removed all process.exit() calls that could cause crashes

Build succeeds every time

Health check passes every time

The container is terminated by Railway, not by my code

Service details:

Service URL: viewsurge-main-production.up.railway.app

Start command: npm start (runs migrations then starts server)

Health check path: /health

Node.js version: 22

Expected behavior: Container should remain running after passing health check

Actual behavior: Container is terminated 3-5 seconds after passing health check, resulting in persistent 502 errors

This has been happening consistently for multiple deployments and restarts. Please investigate why Railway is terminating healthy containers.

$10 Bounty

2 Replies

Try changing your Start Command to something like: npx prisma migrate deploy && node dist/index.js

And use the port provided by Railway to your container automatically (process.env.PORT). This is known to cause 502 HTTP error.

const PORT = process.env.PORT || 3000;


4 months ago

Keep Prisma migrations out of your start command

https://docs.railway.com/guides/pre-deploy-command

prisma generate in build step

prisma migrate deploy in predeploy


Welcome!

Sign in to your Railway account to join the conversation.

Loading...