# How to Deploy a Node.js App in One Command (2026 Guide)

Deploy an Express, NestJS or Fastify app from your terminal with dock deploy: a live HTTPS URL, managed PostgreSQL and logs, starting on a free plan.

URL: https://blog.dockhosting.dev/deploy-nodejs-app-one-command
Published: 2026-11-03 · Updated: 2026-11-03 · Author: Doughmi ILYAS

## Summary

- Install the dock CLI, run dock login, then dock deploy in your project folder: you get a live HTTPS URL.
- Your app must listen on process.env.PORT and have a start script in package.json.
- Attach a managed PostgreSQL database and read DATABASE_URL; Free plan is $0, Hobby ($4/mo) keeps it always on.

ort const meta = {
  title: "How to Deploy a Node.js App in One Command (2026 Guide)",
  seoTitle: "Deploy a Node.js App in One Command (2026 Guide)",
  description:
    "Deploy an Express, NestJS or Fastify app from your terminal with dock deploy: a live HTTPS URL, managed PostgreSQL and logs, starting on a free plan.",
  date: "2026-11-03",
  category: "Guides",
  tags: ["Node.js", "Deployment", "CLI", "Tutorial"],
  stack: ["nodejs", "express", "postgresql"],
  command: "dock deploy",
  takeaways: [
    "Install the dock CLI, run dock login, then dock deploy in your project folder: you get a live HTTPS URL.",
    "Your app must listen on process.env.PORT and have a start script in package.json.",
    "Attach a managed PostgreSQL database and read DATABASE_URL; Free plan is $0, Hobby ($4/mo) keeps it always on.",
  ],
  faq: [
    {
      q: "Do I need a Dockerfile to deploy a Node.js app?",
      a: "No. DockHosting detects package.json, installs dependencies with the package manager that matches your lockfile (npm, pnpm or yarn), runs npm run build if it exists and starts the app with npm start. If your repo has a Dockerfile, it is built instead.",
    },
    {
      q: "Which Node.js versions are supported?",
      a: "Node.js 20 and 22 LTS.",
    },
    {
      q: "Is deploying a Node.js app free?",
      a: "Yes. The Free plan includes 2 projects, 1 managed database, 512 MB of memory and a free .dockhosting.cloud subdomain with HTTPS, with no credit card. Free apps sleep when idle and wake on the next request. Hobby ($4/month) keeps apps always on and adds your own domain.",
    },
    {
      q: "What port should my Node.js app listen on?",
      a: "Read the port from the PORT environment variable (process.env.PORT). The platform sets it and routes HTTPS traffic to it.",
    },
  ],
};

You have a Node.js app that runs on `localhost:3000`. You want it on the internet with HTTPS, a database, and logs, without writing a Dockerfile, renting a VPS, or wiring up nginx and Certbot.

This guide takes you from a local project to a live `https://yourapp.dockhosting.cloud` URL using the [dock CLI](https://dockhosting.dev/cli). It works for Express, NestJS, Fastify, plain TypeScript projects and monorepos.

**What you'll end up with:**

- A production deploy from one command: `dock deploy`
- Automatic HTTPS on a free subdomain
- A managed PostgreSQL database connected through `DATABASE_URL`
- Live logs in your terminal

## 1. Make your app production-ready (two small checks)

### Listen on `PORT`

The platform tells your app which port to use through the `PORT` environment variable. Hard-coding `3000` is the most common reason a first deploy fails.

```js
// server.js (Express)
import express from "express";

const app = express();
app.get("/", (req, res) => res.send("Hello from DockHosting"));

const port = process.env.PORT || 3000;
app.listen(port, () => console.log(`Listening on ${port}`));
```

### Have a `start` script

DockHosting detects Node.js from `package.json`, runs `npm run build` if you have a build script, then starts the app with `npm start`:

```json
{
  "scripts": {
    "build": "tsc",
    "start": "node dist/server.js"
  }
}
```

Commit your lockfile. The build uses the package manager that matches it (`package-lock.json` → npm, `pnpm-lock.yaml` → pnpm, `yarn.lock` → yarn), so production installs exactly what you tested.

## 2. Install the dock CLI

macOS and Linux:

```bash
curl -fsSL https://cli.dockhosting.dev/install.sh | sh
```

Windows (PowerShell):

```powershell
irm https://cli.dockhosting.dev/install.ps1 | iex
```

Then sign in. If you don't have an account yet, [create one for free](https://app.dockhosting.dev/register). No credit card is needed.

```bash
dock login
```

## 3. Deploy

From your project folder:

```bash
dock deploy
```

Here's what happens:

1. **Detect.** `package.json` marks it as Node.js. NestJS (`@nestjs/core`) and Express are recognized automatically.
2. **Install.** Dependencies are installed with your lockfile's package manager.
3. **Build.** Your build script runs and an image is built.
4. **Release.** A container starts with automatic HTTPS. The switch is zero-downtime, and the previous image is kept, so a rollback doesn't need a rebuild.
5. **Live.** You get a `https://<project>.dockhosting.cloud` URL.

You don't need GitHub for this. If you'd rather deploy on every push, connect the repository from the dashboard and each push to your branch ships the same way.

## 4. Add a PostgreSQL database

Create a managed PostgreSQL database from the dashboard and attach it to your project. The connection string is injected into your app as `DATABASE_URL`, over a private network, so there's no public port to lock down.

```js
import pg from "pg";

const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL });
const { rows } = await pool.query("select now()");
```

Prisma, Drizzle, Knex and TypeORM all accept the same `DATABASE_URL`. MongoDB (`MONGODB_URI`) and Redis (`REDIS_URL`) attach the same way. For a deeper walkthrough, see [connecting an app to managed PostgreSQL](/connect-app-to-managed-postgresql).

To run a quick query without leaving the terminal, use `dock db sql`.

## 5. Watch logs and restart

```bash
dock logs      # tail build and application logs
dock restart   # restart the running app
```

A supervisor also restarts your process automatically if it crashes.

## Monorepos and custom commands

In a monorepo, set the project's **root directory** (for example `apps/api`) in the dashboard. You can override the build and start commands there too, for example `pnpm --filter api build`.

Background workers, such as a BullMQ consumer, deploy as a separate project and share the same managed Redis queue.

## Free vs. paid: what changes

| | Free | Hobby ($4/mo) | Pro ($9/mo) |
|---|---|---|---|
| Memory | 512 MB | 1 GB | 3 GB |
| Projects / databases | 2 / 1 | 3 / 2 | 10 / 6 |
| Sleeps when idle | Yes | No, always on | No, always on |
| Custom domain | - | 1 | 5 |
| Daily DB backups | - | Kept 3 days | Kept 7 days |

The Free plan is great for side projects and demos. An idle app is scaled to zero and wakes in a few seconds on the next request. Once real users depend on it, Hobby keeps it always on. See [full pricing](https://dockhosting.dev/pricing).

## Troubleshooting checklist

- **Deploy succeeds but the URL times out.** The app isn't listening on `process.env.PORT`.
- **`Cannot find module` at start.** A runtime dependency is in `devDependencies`, or `start` points to a file your build doesn't produce.
- **Database connection refused.** Read `DATABASE_URL` from the environment rather than a local `.env` value that points to `localhost`.

Need help? Ask in our [Discord](https://discord.gg/qvt2uNsZk3) or check the [docs](https://docs.dockhosting.dev/deploying/frameworks).

**Related:** [Free Node.js hosting that doesn't sleep](/free-nodejs-hosting-without-sleeping) · [Deploy an Express + MongoDB API](/deploy-express-mongodb-api)

## FAQ

### Do I need a Dockerfile to deploy a Node.js app?

No. DockHosting detects package.json, installs dependencies with the package manager that matches your lockfile (npm, pnpm or yarn), runs npm run build if it exists and starts the app with npm start. If your repo has a Dockerfile, it is built instead.

### Which Node.js versions are supported?

Node.js 20 and 22 LTS.

### Is deploying a Node.js app free?

Yes. The Free plan includes 2 projects, 1 managed database, 512 MB of memory and a free .dockhosting.cloud subdomain with HTTPS, with no credit card. Free apps sleep when idle and wake on the next request. Hobby ($4/month) keeps apps always on and adds your own domain.

### What port should my Node.js app listen on?

Read the port from the PORT environment variable (process.env.PORT). The platform sets it and routes HTTPS traffic to it.
