Deploy Node.js TypeScript | HTTP Service That Stays Running
Node 24 and TypeScript 7 on Railway, with health and graceful shutdown
Just deployed
Deploy and Host a Node.js + TypeScript Service on Railway
A minimal HTTP service on Node 24 and TypeScript 7 - no framework, but a service that stays up.
About Hosting Node.js with TypeScript
The Node.js TypeScript starter on Railway deploys a repository whose entire program is one line:
console.log(process.env.PORT)
It prints a line and exits. A container that exits is a container the platform marks as stopped - there is nothing to route a domain to and nothing to health-check. One deployment in five reports as healthy, and those are healthy by accident.
This template listens, answers, and shuts down cleanly, which is the smallest thing that deserves to be called a service.
Common Use Cases
- A small JSON API or webhook receiver, without a framework in the way
- A background service that also needs a health endpoint
- A starting point you will grow into Express or Fastify - the shape below does not change
Dependencies for Node.js Hosting
- Nothing. One service, no database, no volume.
Deployment Dependencies
- Node.js: https://nodejs.org/docs
- Source: https://github.com/ak40u/node-ts-railway-starter
Implementation Details
| Method | Path | Does |
|---|---|---|
| GET | / | Lists the endpoints |
| GET | /health | status plus uptime in seconds |
| GET | /echo?message=hi | Echoes the parameter, 400 when it is missing |
The router is a plain object keyed by "METHOD /path". That is not a framework and is not trying to be one - it is there so the interesting parts stay visible: binding PORT, answering a health check, and closing the server on SIGTERM.
That last one matters more than it looks. Railway sends SIGTERM before replacing a container; without a handler, in-flight requests are cut off mid-response on every deploy.
| Variable | Why |
|---|---|
| PORT | The port the server binds; Railway routes the public domain to it |
The health check and restart policy live in railway.json in the repository, so they travel with your code when you fork it.
Why Deploy Node.js on Railway?
Push TypeScript, get a running service on a domain with a health check. No Dockerfile, no build config to maintain, and a deploy that reports honestly whether the process actually came up.
Template Content