Railway

Deploy Node.js — Minimal Web App Starter

Deploy a minimal Node.js web app — HTTPS & Git deploys included

Deploy Node.js — Minimal Web App Starter

Just deployed

Deploy and Host Node.js on Railway

A clean, minimal Node.js web application ready to deploy in one click — a production-ready starting point for building APIs, web services, and backends on Railway. It ships with a working HTTP server, sensible project structure, and zero configuration to get running, so you can skip the boilerplate and start writing your own code immediately. Auto-deploys from GitHub, scales on demand, and runs with automatic HTTPS out of the box.


What This Template Deploys

ServicePurpose
Node.jsA minimal Node.js web server, listening on Railway's assigned port

A single lightweight service. No database or extra infrastructure is bundled, so it stays clean and fast — add a Railway PostgreSQL, Redis, or other service when your app needs it.


About Hosting

This template is a foundation, and it's built to be the simplest possible correct starting point on Railway.

It binds to Railway's port automatically. The server reads the PORT environment variable Railway provides and binds to 0.0.0.0, which is what lets Railway route public traffic to it. This is the single most common mistake in a hand-rolled Node deploy — hardcoding a port, so Railway can't reach the app — and it's handled here so the template just works.

Add infrastructure when you need it. The template is intentionally minimal — no database, no cache, no extra services. When your app needs persistence, add a Railway PostgreSQL or Redis service and reference its connection variables; Railway wires them over the private network. Starting minimal keeps your first deploy fast and your costs low.

Auto-deploys from GitHub. Connect the repository and every push to your default branch redeploys automatically, so your workflow is just git push. No build scripts, SSH, or manual steps.

Bring your own dependencies. Add packages with npm as normal; Railway installs them on build. The template is a starting point, not a framework — use Express, Fastify, Hono, or plain Node, whatever fits your project.

Typical cost: ~$5/month on Railway's Hobby plan for a small service, scaling with your resource usage. Node.js and the template are free and open source.


How It Compares

Node on Railway (this template)HerokuVPS (DIY)Serverless functions
SetupOne clickModerateManual server adminPer-function config
Always-onYesYesYesCold starts
HTTPSAutomaticAutomaticYou configureAutomatic
Auto-deploy from GitYesYesYou configureVaries
Add a databaseOne clickAdd-onManual installExternal
Cost~$5/mo flatFrom $7/moVPS + your timePer invocation

A DIY VPS means managing the server, HTTPS, and deploys yourself. Serverless functions add cold starts and per-invocation billing. Heroku is similar but pricier. This template gives you an always-on Node service with automatic HTTPS and Git deploys at flat cost — the fastest path from empty repo to a live, scalable Node app.


Deploy in Under 5 Minutes

  1. Click Deploy on Railway — the Node.js app builds and starts automatically (~1 minute)
  2. Open the generated Railway URL to see the running server
  3. Connect your GitHub repository for automatic deploys on every push
  4. Add your own routes and code, and git push to deploy
  5. Add a PostgreSQL or Redis service from the Railway dashboard when your app needs it

The app is live and scalable immediately — build your API or web service on top of it.


Common Use Cases

  • REST API backend — a starting point for building JSON APIs for web and mobile apps
  • Web service or microservice — deploy a focused Node service that scales independently
  • Webhook receiver — handle incoming webhooks from Stripe, GitHub, or other services
  • Prototype or MVP — get an idea live fast without server setup, then iterate
  • Backend for a frontend — pair with a static site or SPA as its API layer
  • Learning and experimentation — a clean Node environment to build and test on real infrastructure

Configuration

VariableRequiredDescription
PORTAuto-setRailway assigns this; the server binds to it automatically
NODE_ENVOptionalproduction for optimized runtime behavior
NODE_VERSIONOptionalPin a Node.js major version for reproducible builds

The server binds to Railway's PORT automatically. Don't hardcode a port — the template reads PORT and binds to 0.0.0.0 so Railway can route traffic. This is the most common cause of a Node app deploying but being unreachable, and it's handled here.

Add services as you grow. The template ships with no database by design. Add a Railway PostgreSQL or Redis service when needed and reference its variables — Railway connects them over the private network.


Dependencies for Node.js Hosting

  • Railway account — ~$5/month on the Hobby plan for a small service
  • A GitHub repository for auto-deploys (optional but recommended)
  • npm packages your application needs (installed automatically on build)
  • Optional: a Railway database service when your app needs persistence

Deployment Dependencies

Implementation Details

The template runs a minimal Node.js HTTP server that reads Railway's injected PORT variable and binds to 0.0.0.0, so the platform can route public traffic to it — the essential detail for any Node app on Railway. Railway builds the app with Nixpacks (or your Dockerfile if present), installing npm dependencies automatically, and serves it over automatic HTTPS with no certificate configuration.

The service is intentionally dependency-light: there's no bundled database or cache, keeping the base image small and the first deploy fast. Persistence and other infrastructure are added as Railway services when the application needs them, connected through reference variables over the private network. Connecting a GitHub repository enables automatic redeploys on every push to the default branch, so the deploy workflow reduces to committing code.

Because it's a plain Node foundation rather than an opinionated framework, you're free to build with Express, Fastify, Hono, or the standard library, and to structure the project however suits your application.


Frequently Asked Questions

Is this tied to a framework? No. It's a minimal Node.js foundation, so you can use Express, Fastify, Hono, or plain Node and structure the project however you like — add the framework you prefer with npm.

How do I add a database? Add a PostgreSQL or Redis service from the Railway dashboard, then reference its connection variables in your app. Railway connects them over the private network automatically.

Why does my app need to use the PORT variable? Railway assigns the port and routes traffic to it. If you hardcode a different port, the app runs but Railway can't reach it. This template reads PORT and binds to 0.0.0.0 so it works out of the box.

Does it auto-deploy from GitHub? Yes. Connect your repository and every push to the default branch triggers a redeploy — no manual steps or build scripts needed.

How do I scale it? Adjust CPU and memory from the Railway dashboard, or run multiple replicas. The service scales vertically and horizontally without code changes.

Is HTTPS included? Yes. Railway provides automatic HTTPS on your generated domain and any custom domain you add, with no certificate setup.

Can I use TypeScript? Yes. Add TypeScript and a build step to your project; Railway runs your build command on deploy. The template is a plain starting point you can extend however you need.


Why Deploy 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 this Node.js template on Railway you get a live, always-on web service in one click — automatic HTTPS, Git-based deploys, and one-click databases when you need them, at flat cost. A clean foundation to build your API, service, or backend on, with zero server administration.


Template Content

More templates in this category

View Template
NEW
Paperless-ngx
Document management with OCR on Railway with PostgreSQL and Redis

INAPP
1
View Template
open-excalidraw
Self-hostable collaborative drawing built on Excalidraw

Prateek Mohanty
1
View Template
caring-vibrancy
Deploy and Host caring-vibrancy with Railway

5