Prevent deploy cutover if service crashes immediately

2 months ago

Is there a way to only switch traffic to a new deploy once the service starts successfully?

I had a case recently where a service crashed immediately after starting, but it was presumed healthy by Railway, so the deployment cutover proceeded. Ideally, the orchestrator would wait a second or two for any immediate runtime failure, and treat those similarly to build failures (i.e., don't remove old deploys yet).

I suppose a healthcheck endpoint could be used here, but this seems like a simple enough case to infer health (immediate crash = not healthy), and was wondering if there's any configuration I can set around this (e.g., if a service hasn't crashed 10s after start, assume healthy)

Appreciate the help!

Solved

1 Replies

Hey Neall! (Cool product/company btw!)

Railway doesn't have automatic crash detection for deployments, but healthchecks are the perfect solution for this. When you set up a healthcheck endpoint, Railway will query it and wait for an HTTP 200 response before switching traffic to your new deployment. If your service crashes immediately, it won't respond to the healthcheck, the deployment will fail after the timeout period, and your previous version stays live.

To get this working, add a simple health endpoint to your service (like /health) that returns a 200 status code when everything's running normally, then configure that path in your service settings. It's a lightweight addition that gives you exactly what you need—traffic only switches once the new deployment is confirmed healthy.

By default, healthchecks wait 300 seconds before timing out, but you can speed that up using the RAILWAY_HEALTHCHECK_TIMEOUT_SECvariable if you want faster failure detection for immediate crashes. This approach gives you explicit control and works reliably across different application types and startup behaviors.

Best,
Angelo


Status changed to Awaiting User Response Railway 2 months ago


Railway
BOT

2 months ago

This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!

Status changed to Solved Railway about 2 months ago


Loading...