How to monitor a Railway deployment
Railway's healthcheck only runs when you deploy. After that, nothing checks your app unless you set it up. How to configure the healthcheck, and what to monitor from outside.
Railway builds and runs your code and gives you a URL. It also has a healthcheck, but that healthcheck only runs when you deploy. Railway's docs are explicit that it isn't used for continuous monitoring. Once a deployment is live, nothing checks whether your app keeps responding. That part you set up yourself.
Railway's healthcheck
When you set a healthcheck path, Railway calls it after each new deployment starts. Railway only makes the new deployment active, and the old one inactive, once the path returns a 2xx response. If it doesn't within the timeout, the deploy is marked as failed. The default timeout is 300 seconds.
You set the path in the service settings. If you define your services in code with Railway's Infrastructure as Code, it's the healthcheck option:
import { defineRailway, project, service } from "railway/iac";
export default defineRailway(() => {
const api = service("api", {
healthcheck: "/health",
healthcheckTimeout: 30,
});
return project("my-project", {
resources: [api],
});
});Older services may still use healthcheckPath in railway.json or railway.toml. Railway has deprecated those files, and legacy services can use them until 1 December 2026.
Two details from Railway's docs that trip people up:
- The healthcheck request uses the hostname
healthcheck.railway.app. If your app only accepts requests for specific hosts, add that one. - Your app has to listen on the
PORTvariable Railway injects, or the healthcheck can't reach it.
What to monitor
Your public URL. The *.up.railway.app domain or your custom domain, over HTTPS. That's what your users hit, and it tests DNS, TLS and routing along with the app.
A health endpoint that checks dependencies. The same path you use for Railway's healthcheck works well here, as long as it does more than return 200. Have it check the database and anything else the app needs to serve requests. If you're on Elixir, I wrote about a minimal health check plug for Plug and Phoenix.
The endpoints your users call. A health endpoint can pass while a specific route fails, for example because of a missing environment variable or a migration that didn't run. Monitor the routes that matter.
Your custom domain's certificate. Railway manages the certificate, but it depends on your DNS being set up correctly. Larm checks certificate expiry on every HTTPS monitor and alerts at 28, 14, 7 and 1 days before it runs out.
Railway-specific things to know
Serverless services sleep. Railway's Serverless setting, formerly called App Sleeping, stops a service after about 5 to 10 minutes without outbound traffic. The next request wakes it, and Railway's docs say that first request may get a 502 Bad Gateway while the service boots. If you use Serverless on a service you monitor, expect that, and give the monitor a timeout long enough for the boot.
Private networking. Services in a project can talk to each other over Railway's private network. An external monitor can't see those connections, so if your API depends on a private Postgres or Redis, the API's health endpoint has to check them.
Regions. Railway runs in a few regions, such as us-west2 in California and europe-west4-drams3a in Amsterdam. If your users are spread out, checking from several locations shows you what response times look like away from your region.
Setting it up in Larm
Create an HTTP monitor in Larm with your Railway URL. Larm checks it from several locations and only marks it down when a majority of probes see the failure.
Check interval. 1-minute checks for production, on Pro. The free plan checks every 3 minutes.
Expected status code. The default is 200. If your health endpoint returns 204, set that instead.
Keywords. If your health endpoint returns {"status":"ok"}, add "ok" as an expected keyword. The check then fails if the endpoint returns 200 with an error in the body.
Timeout. Larm's default is 10 seconds, which is fine for services that stay running.
Workers. For background workers that don't serve HTTP, use a heartbeat monitor. The worker pings a URL after each run, and you get an alert when the pings stop.
Larm's free plan includes 15 monitors, checked from all probe locations.
Start monitoring in minutes.
Free plan. 15 monitors. Multi-probe voting. No credit card.
Sign Up Free