Railway killing my Node app a few seconds after start, log shows no errors
ruba
HOBBYOP

3 months ago

Hi Railway Support Team,

I am experiencing a persistent issue with my Node.js deployment. My application container is being actively stopped by the system exactly 6-7 seconds after every single startup, rendering the app inaccessible.

The Issue: Every time the container starts, whether from a manual redeploy or an incoming web request (from sleep), my logs show a successful startup and port binding, followed immediately by a Stopping Container event.

What I've already checked/fixed:

  • Port Binding: The Express server correctly binds to 0.0.0.0 and process.env.PORT.
  • Database: I am using better-sqlite3 attached to a persistent volume, and it connects without issue.
  • Healthchecks: I suspected the default healthcheck was hitting my / route (which returns a 302 redirect for unauthenticated users) and killing the app. So, I created a public /healthz route (returns 200 OK {"status": "ok"}) and added a railway.toml file setting healthcheckPath = "/healthz".
  • Sleep State: I've added a self-ping interval inside the app that uses fetch to ping the public Railway domain every 5 minutes to prevent Hobby plan sleep.

Despite these fixes, the deployment logs still show this exact repeating pattern. Interestingly, yesterday the service became active again at around 15:00, but this morning the shutdown behavior returned.

Since my app isn't crashing (there are no stack traces, memory limit errors, or unhandled exceptions), and I have explicitly configured the 200 OK health check, could you please investigate why the platform ingress or health check orchestrator keeps killing this container?

Thank you,

$10 Bounty

1 Replies

Status changed to Awaiting Railway Response Railway 3 months ago


I suggest you remove the self-ping mechanism to prevent your service from sleeping, as you can disable serverless in your Service Settings > Enable Serverless, since you are on the hobby plan**.** This is likely causing your container to be stopped.


Welcome!

Sign in to your Railway account to join the conversation.

Loading...