---
title: "Deploy Node.js"
description: "A minimal Node.js web application for REST APIs or web servers"
category: "Other"
url: https://railway.com/deploy/nodejs-1
---

# Deploy Node.js

A minimal Node.js web application for REST APIs or web servers

**[Deploy Node.js on Railway](https://railway.com/template/nodejs-1)**

- **Creator:** John Fu Lin's Projects
- **Category:** Other
- **Total deploys:** 69

## Template content

### nodejs-railway

- **Source:** https://github.com/aeither/nodejs-railway
- **Health check:** /health
- **Public domain:** Yes

## Documentation

# Deploy and Host Node.js on Railway

[![Deploy on Railway](https://railway.com/button.svg)](https://railway.com/deploy/YDRT1o?referralCode=CREDITS&utm_medium=integration&utm_source=template&utm_campaign=generic)

Node.js is a JavaScript runtime built on Chrome's V8 engine that enables developers to build scalable server-side applications. It uses an event-driven, non-blocking I/O model that makes it lightweight and efficient for real-time applications and APIs.

## About Hosting Node.js

Hosting Node.js applications requires a platform that supports JavaScript runtime environments and can handle asynchronous operations efficiently. Your Node.js server needs to listen on a dynamically assigned port, manage dependencies through npm or yarn, and have access to environment variables for configuration. The hosting platform should provide automatic restarts on crashes, log streaming for debugging, and the ability to scale based on traffic demands. Modern hosting solutions detect Node.js projects automatically by reading the `package.json` file and execute the appropriate start command.

## Common Use Cases

- RESTful APIs and microservices for web and mobile applications
- Real-time applications like chat servers, collaboration tools, and live dashboards
- Backend services for static site generators and serverless functions

## Getting Started

### Setup

1. Clone this repository or use the Railway deploy button above
2. Install dependencies:
```bash
npm install
```

### Running Locally

**Development mode** (with hot-reload):
```bash
npm run dev
```

**Production mode**:
```bash
npm start
```

The server will start on `http://localhost:3000` (or the port specified in the `PORT` environment variable).

### Testing the API

Once running, test the endpoints:
```bash
# Root endpoint
curl http://localhost:3000/

# Health check
curl http://localhost:3000/health
```

## Dependencies for Node.js Hosting

- Node.js runtime (v14 or higher recommended)
- npm or yarn package manager

### Deployment Dependencies

- [Express.js](https://expressjs.com/) - Fast, unopinionated web framework
- [Node.js Documentation](https://nodejs.org/docs/latest/api/)

### Implementation Details

This template includes a minimal Express.js server with JSON parsing middleware and two endpoints:

```javascript
// Root endpoint with timestamp
app.get('/', (req, res) => {
  res.json({ 
    message: 'Welcome to Node.js API',
    status: 'running',
    timestamp: new Date().toISOString()
  });
});

// Health check endpoint
app.get('/health', (req, res) => {
  res.json({ status: 'ok' });
});
```

The server reads the `PORT` environment variable (automatically set by Railway) and includes development mode with hot-reload using Node.js `--watch` flag.

## 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 Node.js on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


## Similar templates

- [Rocky Linux](https://railway.com/deploy/rocky-linux) — Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀
- [Foundry Virtual Tabletop](https://railway.com/deploy/X5tR6G) — A Self-Hosted & Modern Roleplaying Platform
- [Letta Code Remote](https://railway.com/deploy/letta-code-remote) — Run a Letta Code agent 24/7. No inbound ports, just deploy.

Open this page in a browser: https://railway.com/deploy/nodejs-1
