Service is unexpectedly stopping
garett2544
PROOP

2 months ago

Hi Railway Support,

I'm experiencing an issue where my Node.js/Express container is being stopped immediately after the health check passes. The deployment is marked as "successful" with 1 replica active, but the container keeps receiving SIGTERM and restarting in a loop.

Project Details:

What happens:

  1. Container starts successfully

  2. Server binds to 0.0.0.0:$PORT (port 8080)

  3. Health check endpoint /api/health returns 200 OK

  4. Deployment is marked "successful"

  5. Container immediately receives SIGTERM and stops

  6. Cycle repeats

Logs showing the issue:

Starting Container

9:39:08 PM [express] serving on port 8080

9:39:08 PM [express] NODE_ENV: production

9:39:08 PM [express] Server is ready to accept connections

9:39:08 PM [express] GET /api/health 200 in 8ms :: {"status":"ok","timestamp":"2026-01-13T21:39:08.811Z"}

Stopping Container

[SIGNAL] Received SIGTERM - Railway is stopping the container

What I've already tried:

  • Using node dist/index.cjs directly (not npm scripts)

  • Adding proper signal handlers to confirm SIGTERM is received

  • Adding a Procfile with web: node dist/index.cjs

  • Adding keep-alive intervals (heartbeat every 30 seconds)

  • Binding to 0.0.0.0 on the PORT environment variable

  • Health check returns valid 200 response with JSON body

Configuration:

  • Start command: NODE_ENV=production node dist/index.cjs

  • Health check path: /api/health

  • railway.json configured with healthcheckPath and restartPolicyType: ON_FAILURE

Metrics:

  • CPU usage: Normal (near 0%)

  • Memory usage: ~100MB (well within limits)

  • No 5xx errors

  • Health check returns 200

The container is healthy, the health check passes, but Railway keeps sending SIGTERM to stop it. Could you please investigate why the orchestrator is stopping a healthy container?

Thank you for your help.

$10 Bounty

1 Replies

Railway
BOT

2 months 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 Railway about 2 months ago


eho99
FREE

2 months ago

Hey! Found these that might be useful.
https://station.railway.com/questions/node-container-doesn-t-handle-sigterm-a987cd62
"You are running your application via npm, but npm is not passing SIGTERM correctly to your application. This is a widely known issue that happens everywhere, not just on Railway."


Loading...