Deploy Node.js + Express Starter
Deploy a minimal Node.js + Express web app with HTTPS in one click.
nodejs
Just deployed
Deploy and Host Node.js on Railway
Node.js is the JavaScript runtime behind millions of web apps, with 122,000+ GitHub stars, and Express is its most popular web framework. This template deploys a minimal Node.js + Express app to Railway with HTTPS in about a minute. Heroku's always-on Basic dyno costs $7/month — a small Node app on Railway typically runs for a few dollars a month, and you get the full code to build on.
What This Template Deploys
| Service | Purpose |
|---|---|
| nodejs | Express 4 web app built from GitHub (app.js), serving static files from public/ with a custom 404 page. Public HTTPS domain. |
A single stateless service: Railway builds it straight from the repository with Railpack, no Dockerfile needed. Add Postgres, Redis or MongoDB from the Railway canvas when your app needs data.
About Hosting Node.js
A production Node app needs a process that stays up, a port the platform can route to, HTTPS, logs and a way to redeploy on every push. On a VPS that's PM2, Nginx and Certbot; on serverless platforms it's a rewrite into functions with time limits.
On Railway, the app runs as a normal long-lived Node process: WebSockets, background timers and streaming responses all work. Railway injects PORT, the app already reads process.env.PORT, and every push to your fork redeploys automatically.
It's a starter, not an app. You get a clean Express skeleton to extend. There's no database or authentication included, and the container filesystem resets on each deploy, so store data in a database or a Railway volume.
Typical cost: ~$1–5/month in Railway usage for a small app, within the $5 Hobby plan. Heroku charges $5 for an Eco dyno that sleeps when idle and $7 for one that stays up; Render's free tier spins down after 15 minutes without traffic.
Deploy Node.js in Under 2 Minutes
- Click Deploy on Railway — Railway forks the code to your GitHub and builds it (~1 minute).
- Open the generated public URL to see the app running.
- Clone your new repository and edit
app.js,routes/orpublic/. - Push to GitHub — Railway redeploys automatically.
- Add a database from the canvas and read its URL from a variable reference.
No server to patch. No Nginx. No dyno that falls asleep.
Common Use Cases
- Heroku alternative for Node — "host node js app" without dyno sleep or per-add-on pricing
- REST APIs and backends — start from Express and add your routes
- Webhooks and integrations — always-on endpoints for Stripe, GitHub or Slack events
- Real-time apps — WebSockets and long-lived connections that serverless can't hold
- Learning and prototypes — a live URL for a side project in minutes
- Full-stack apps — pair it with Railway Postgres or Redis
Configuration
| Variable | Required | Description |
|---|---|---|
PORT | Auto-set | 3000. The app listens on process.env.PORT; keep it in sync with the domain's target port. |
NODE_ENV | Optional | Set to production for Express production optimisations. |
DATABASE_URL, … | Optional | Add when you attach a database — use Railway variable references. |
Keep the port in sync. If you change PORT, update the public domain's target port in Railway too, or the site returns 502 errors.
Node.js on Railway vs. Alternatives
| Node.js on Railway | Heroku | Render | Vercel | |
|---|---|---|---|---|
| Monthly cost | ~$1–5 usage | $5 Eco, $7 Basic | Free (sleeps) or paid | Free (non-commercial), $20 per seat Pro |
| Always-on server | ✅ Yes | ⚠️ Eco sleeps when idle | ⚠️ Free spins down | ❌ Serverless functions |
| WebSockets and long requests | ✅ Yes | ✅ Yes | ✅ Yes | ⚠️ Function time limits |
| Database in the same project | ✅ One click | ✅ Add-ons | ✅ Yes | ⚠️ Via marketplace |
| Deploy on git push | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
| Commercial use on entry plan | ✅ Yes | ✅ Yes | ✅ Yes | ❌ Hobby is non-commercial |
| License | ✅ MIT starter code | ❌ Proprietary platform | ❌ Proprietary platform | ❌ Proprietary platform |
Dependencies for Node.js Hosting
- Railway account — Hobby ($5/month) covers a small app.
- A GitHub account — Railway forks the starter into it so you own the code.
Deployment Dependencies
- Node.js — runtime
- Express — web framework
- Railpack — Railway's zero-config builder
- Railway Docs — domains, variables and databases
Implementation Details
Railpack detects package.json, installs dependencies and runs npm start (node app.js). Express serves public/ as static files, mounts the routes in routes/index, and falls back to views/404.html for unknown paths.
The app binds to process.env.PORT, which Railway sets. Keep state out of the container: use Railway Postgres, Redis or a volume for anything that must survive a redeploy.
Frequently Asked Questions
What does this Node.js template include? A minimal Express 4 app with static file serving, a router and a 404 page, deployed to a public HTTPS URL. It's a clean starting point you extend with your own routes.
How much does it cost compared to Heroku? A small app usually uses $1–5/month of Railway usage, covered by the $5 Hobby plan. Heroku's Eco dyno is $5 but sleeps when idle, and an always-on Basic dyno is $7.
Why does my Node app show a 502 or "Application failed to respond"?
The app must listen on process.env.PORT, and the public domain must target the same port. This template does both — if you changed the port, update the domain's target port to match.
Do I lose data when I redeploy? Files written inside the container are reset on each deploy. Store data in Railway Postgres, Redis or MongoDB, or mount a volume for files.
Can I use TypeScript, Next.js or another framework?
Yes. Railpack builds most Node projects automatically — change package.json and the start script, push, and Railway rebuilds.
Does the app sleep when nobody visits? No. It runs as an always-on process, unlike free tiers that spin down. You can enable Railway's serverless sleeping per service if you want to save usage.
Why Deploy and Host Node.js on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying Node.js on Railway, you get an always-on Express app with HTTPS and git-push deploys for a few dollars a month, ready to grow into a full backend.
Template Content
nodejs
alphasecio/nodejs