# NestJS hosting in 2026: how to deploy a NestJS app, and where

> A NestJS app in production is built to dist once and started with node dist/main, listens on process.env.PORT on every interface, answers a health check that respects its global prefix, and migrates its Prisma or TypeORM schema before it takes traffic. On Livops a Nest repository builds and starts from a push, for 39 credits a month (39,000 so'm). Here is how Render, Railway, Fly.io and a VPS with pm2 compare.

Source: https://livops.dev/en/hosting/nestjs-hosting

By Livops team, the people who build and run Livops. Updated 23 November 2026.

A NestJS app is a TypeScript project that compiles to plain JavaScript and runs as one long-lived Node process. Hosting it well comes down to doing the compile once at build time, starting the output rather than the CLI, listening where the platform sends traffic, and getting the database schema right before the first request. This page covers each, compares Render, Railway, Fly.io and a VPS with pm2 with each provider's own numbers, and ends with exactly what Livops reads from a Nest repository.

## What does a NestJS app need in production?

### A build to dist, and node dist/main

`npm run build` runs `nest build`, a wrapper around the TypeScript compiler, and writes the compiled app to `dist`; production starts it with `node dist/main.js`[2]. If `tsconfig.json` also compiles `.ts` files in the project root, the entry moves to `dist/src/main.js`[2] — check which one your build makes before writing the start command. `nest start` is the same thing with `nest build` run first[2], so as a production start it compiles the project again on every boot.

### process.env.PORT, on every interface

The Nest CLI writes `await app.listen(process.env.PORT ?? 3000)` into `main.ts`[1], and the platform has to route traffic to that port[2]. Leave the host out: with no host, Node accepts connections on `::`, or `0.0.0.0` when IPv6 is not available[8], which is what a container needs. `app.listen(port, 'localhost')` makes the app reachable from inside the container only.

```ts
async function bootstrap() {
  const app = await NestFactory.create(AppModule)
  app.setGlobalPrefix('api', { exclude: ['health'] })
  app.enableShutdownHooks()
  await app.listen(process.env.PORT ?? 3000)
}
bootstrap()
```

### `NODE_ENV=production`

Nest calls it good practice: Node and Nest behave the same either way, but some libraries change their behaviour on it, debugging output for example[2].

### A health check that knows the global prefix

`app.setGlobalPrefix('api')` puts every route under `/api`, and the `exclude` option keeps chosen routes out of it[3]. A health check at `/health` that you forgot to exclude is really at `/api/health`, and a platform probing `/health` sees a 404 and never sends traffic. Nest's own advice for health checks is `@nestjs/terminus`[2], which has indicators for TypeORM and Prisma that check the database answers[4]. For the check a platform uses to decide whether a new version started, a route that does not touch the database is usually the safer one: a slow database should not keep a healthy app out of service.

### A clean stop on SIGTERM

Before a new version replaces the old one, the old process receives a termination signal. Shutdown hooks, `onModuleDestroy()` and `onApplicationShutdown()` among them, only run on it after `app.enableShutdownHooks()`, and they are off by default[5]. Turn them on, and Prisma or TypeORM close their connections instead of being cut off.

### A database, and migrations that are not `synchronize`

With **Prisma**, `migrate dev` is a development command that should never be used in production; production applies migrations with `prisma migrate deploy`, generally as an automated step of the deploy[7]. With **TypeORM**, Nest's documentation says not to use `synchronize: true` in production, because you can lose production data; apply migrations at start with `migrationsRun` and the compiled migration files, or with `typeorm migration:run` as a deploy step[6]. Either way, the database address comes from an environment variable, never from the repository.

## The options at a glance

| Option | What it is | Smallest paid always-on process | PostgreSQL | What you still maintain |
| --- | --- | --- | --- | --- |
| Livops | A platform; servers in Uzbekistan | From 39 credits (39,000 so'm) a month | 500 MB free, one per team; 1 GB for 9 credits a month | Your code |
| A VPS with pm2 | A virtual machine with root | 82,000 so'm a month: 1 vCPU, 2 GB, 30 GB HDD (SmartCloud)[11] | Whatever you install | The system, Node, pm2 and its startup script, a reverse proxy, HTTPS, backups, deploys |
| Render | A platform with web services | $7 a month: 0.5 CPU, 512 MB[12] | From $6 a month: 256 MB, plus $0.30 per GB of storage[12] | Your code |
| Railway | A platform billed by usage | Hobby: $5 a month, including that much usage; then about $10 per GB of memory and $20 per vCPU a month[14] | A service billed by the same usage, its volume about $0.15 per GB a month[14] | Your code |
| Fly.io | Virtual machines billed by the second | $2.19 a month for shared-cpu-1x with 256 MB; $3.69 with 512 MB[16] | Managed Postgres from $4 a month (Developer)[16] | Your code, and its Docker image |

Other providers' prices are from each provider's own page, read on 23 November 2026; the dates are in Sources below. Livops prices are the ones the cabinet bills today.

## Each option

### Livops

A Nest repository is recognised from `package.json`, built with its own build script and started from `start:prod` when `start` is the development one (details below). Prisma's client is generated and its migrations applied for you. Payment is in so'm through Payme or Click, with no card, and the servers are in Uzbekistan — close to users there, farther from users elsewhere. You do not get root, one app's memory stops at 2 GB, and PostgreSQL takes 20 connections at once with no built-in pooler yet; for more than that, a VPS or a bigger platform database fits better.

### A VPS with pm2

The most machine for the money: SmartCloud's cheapest 2 GB plan is 82,000 so'm a month[11], and several Nest services fit on it. pm2 is the usual process manager: cluster mode runs one process per CPU without code changes and reloads them with no downtime[10], and `pm2 startup` with `pm2 save` brings the list back after the machine reboots[9]. Everything else is yours too: Node itself, nginx or Caddy in front, a certificate, PostgreSQL and its backups, the deploy script that builds and reloads, and the system's security updates.

### Render

The smallest paid web service is $7 a month for 0.5 CPU and 512 MB, and PostgreSQL starts at $6 for 256 MB[12] — fixed prices, easy to plan around. The Hobby workspace is $0 plus compute, and Pro, with horizontal autoscaling, is $25 a month plus compute[12]. Render takes credit and debit cards[12].

### Railway

The Hobby plan is $5 a month including that much usage; past it, memory is about $10 per GB and CPU about $20 per vCPU a month, billed by the second[14]. Hobby services run always on, and Postgres, Redis, MySQL and MongoDB are one click away, on the Free plan too[14]. Its regions are California, Virginia, Amsterdam and Singapore[15]. It is paid by credit card[14].

### Fly.io

The lowest dollar price for the API itself: $2.19 a month for 256 MB and $3.69 for 512 MB, billed by the second while it runs[16]. A compiled Nest app with an ORM is more comfortable in 512 MB than in 256. Managed Postgres starts at $4 a month on the Developer plan[16]. Fly.io's page says every organisation apart from linked ones needs a credit card on file, and that a new account gets $1 of credit with no card[16].

## VPS or platform: what do you maintain?

On a VPS, Nest is the easy part. The work is around it: a pm2 startup script that survives a reboot, a reverse proxy, certificates that renew, a deploy that builds, migrates and reloads in the right order, database backups, and the updates nobody reminds you about. In return you get root, any system package, and as many services on one machine as it holds. On a platform you hand over a repository and get an address; the build, the start and the rollback are the platform's. If running servers interests you, a VPS teaches you more and costs less per service once you run several. If the API is the point, use a platform.

## Where can you host a NestJS app for free?

- **Livops** has no free tier for apps. On an account that has not paid yet, the first bot or app runs for 15 minutes on a zero balance, once, so you can call it. One 500 MB database per team is free, and starts once the account has credits.
- **Render** gives free instances to web services and PostgreSQL. A free web service spins down after 15 minutes without inbound traffic and takes about a minute to start again, and a free database expires 30 days after it is created[13].
- **Railway** has a Free plan with $1 of usage a month and up to 0.5 GB of memory per service, whose services sleep after 5 to 10 minutes without outbound traffic; a trial gives $5 of credit for 30 days, with no card[14].
- **Fly.io** starts every new account on a Free plan: $1 of credit with no card, and $5 of usage a month once a card is added, with limits such as up to 3 Machines[16].

## Deploy NestJS on Livops

1. Push the repository the Nest CLI made: `package.json` with `build`, `start` and `start:prod` scripts, and `src/main.ts` listening on `process.env.PORT`. In the cabinet, click **New project** and choose the repository, or upload the folder as a `.zip`.
2. Under **Databases**, add PostgreSQL. `DATABASE_URL` and the `PG*` variables are written into the service by themselves.
3. Put your own keys under **Variables**, marked as secret where they are secrets, and `NODE_ENV=production` if your code reads it.
4. Deploy. The log shows the install, the build and the start, and the app gets a `<name>.livops.app` address with HTTPS.

What Livops reads from the repository:

- **The type.** `@nestjs/core` among the runtime dependencies, not only in `devDependencies`, makes it a Node server, and `@nestjs/platform-express` or `@nestjs/platform-fastify` makes it a web app with an address.
- **Build.** `npm run build`, when `package.json` has a build script; for a Nest project that is `nest build`.
- **Start.** `npm run start`. When `start` is a development command — `nest start`, `nodemon`, `--watch`, `ts-node-dev`, `tsx watch` — and a `start:prod` script exists, `npm run start:prod` runs instead, which the Nest CLI writes as `node dist/main`. A `start:prod` that runs `pm2` is not used: `pm2 start` puts the app in the background and returns.
- **Prisma.** With `prisma` among the packages and `prisma/schema.prisma` in the repository, `prisma generate` runs before the build unless one of your install or build scripts already runs it. With migrations in `prisma/migrations` and a database connected (`DATABASE_URL` set), `prisma migrate deploy` runs before every start, unless the start already runs it. A failed migration does not stop the start; the log says `Livops: migrate failed, starting anyway`.
- **TypeORM.** Nothing is run for you. Use `migrationsRun` as above, or make the migration the project's **pre-deploy command**: if it fails, the new version is not started and the old one keeps serving.

To set any of it yourself, put `livops.json` in the repository root:

```json
{
  "kind": "web",
  "build": "npm run build",
  "start": "node dist/main.js",
  "healthPath": "/health",
  "memory": 512
}
```

When the app runs:

- **`PORT`** is 3000 unless you change it, and a new version has a minute to answer on it. With `healthPath`, that path is what Livops checks to know the app is alive — write it with the global prefix unless you excluded the route, `/api/health` for the main.ts above without its `exclude`.
- **If the new version does not start**, the version that worked keeps serving; if the build fails, the running version is left alone. Recent versions stay in **Deploys** for a one-click rollback.
- **Connections.** PostgreSQL accepts 20 connections at once, and a built-in pooler (PgBouncer) is not offered yet, so keep the pool small: on Prisma 6, `?connection_limit=5` in `DATABASE_URL`; on Prisma 7, `max: 5` in the `@prisma/adapter-pg` options, which default to 10. Keep TypeORM's pool as small.
- **Memory** is a tier of 256, 512, 1024 or 2048 MiB, set with `memory` in `livops.json` when the project is created and in the settings afterwards; the tier is part of what you pay for. An app that runs out is stopped, and the log says `Killed` or exit code 137.
- **Files** written to `/app/data` (the `DATA_DIR` variable) survive restarts and deploys; the code folder is read-only and `/tmp` is wiped. Uploads that matter go to an S3 storage bucket, and orders and users to the database, which is backed up every night.

A NestJS app is **from 39 credits a month (39,000 so'm)**. One credit is 1,000 so'm, and bought credits never expire. See [Pricing](https://livops.dev/en/docs/pricing) for plans, which give more credits than they cost, [Databases](https://livops.dev/en/docs/databases) for sizes and connection limits, and [Frameworks and livops.json](https://livops.dev/en/docs/frameworks) for every field.

## Questions

**Which command does Livops start a NestJS app with?**

The start script in package.json. When start is a development command such as nest start, nodemon or a --watch, and a start:prod script exists, npm run start:prod runs instead, which in a project made by the Nest CLI is node dist/main. The build script, nest build, runs during the build.

**Which port and host should main.ts use?**

await app.listen(process.env.PORT ?? 3000), the line the Nest CLI writes, with no host. PORT is 3000 on Livops unless you change it. Do not pass localhost or 127.0.0.1: then only the container itself can reach the app.

**Are Prisma migrations run?**

Yes, when the repository has migrations in prisma/migrations and a database is connected: prisma migrate deploy runs before every start, unless your start script already runs it. If it fails, the app still starts and the log says so. prisma generate runs before the build when prisma/schema.prisma is there and none of your scripts runs it.

**What about TypeORM migrations?**

Livops does not run them for you. Either set migrationsRun with the compiled migrations in your TypeORM options, or make typeorm migration:run the project's pre-deploy command, so a failed migration keeps the old version serving. Keep synchronize off in production.

**Do I need pm2 on Livops?**

No. Start node directly. A start:prod that runs pm2 is not used, because pm2 start puts the app in the background and returns, and the container would end as soon as it started.

**How much does a NestJS app cost on Livops?**

From 39 credits a month, which is 39,000 so'm at 1,000 so'm a credit; the memory tier is part of the price. One 500 MB PostgreSQL database per team is free. There is no free tier for apps; on an account that has not paid yet, the first app runs for 15 minutes on a zero balance, once.

**Who wrote this comparison?**

The Livops team. Every price and limit of another provider on this page links to that provider's own page, with the day we read it.

## Sources

1. [NestJS — First steps](https://docs.nestjs.com/first-steps). Checked 23 November 2026.
2. [NestJS — Deployment](https://docs.nestjs.com/deployment). Checked 23 November 2026.
3. [NestJS — Global prefix](https://docs.nestjs.com/faq/global-prefix). Checked 23 November 2026.
4. [NestJS — Health checks (Terminus)](https://docs.nestjs.com/recipes/terminus). Checked 23 November 2026.
5. [NestJS — Lifecycle events](https://docs.nestjs.com/fundamentals/lifecycle-events). Checked 23 November 2026.
6. [NestJS — TypeORM](https://docs.nestjs.com/data/typeorm). Checked 23 November 2026.
7. [Prisma — Development and production](https://www.prisma.io/docs/orm/prisma-migrate/workflows/development-and-production). Checked 23 November 2026.
8. [Node.js — net, server.listen()](https://nodejs.org/api/net.html). Checked 23 November 2026.
9. [PM2 — Startup script](https://pm2.keymetrics.io/docs/usage/startup/). Checked 23 November 2026.
10. [PM2 — Cluster mode](https://pm2.keymetrics.io/docs/usage/cluster-mode/). Checked 23 November 2026.
11. [SmartCloud — VDS plans](https://smartcloud.uz/cloud-services/vds/). Checked 23 November 2026.
12. [Render — Pricing](https://render.com/pricing). Checked 23 November 2026.
13. [Render — Deploy for free](https://render.com/docs/free). Checked 23 November 2026.
14. [Railway — Pricing](https://railway.com/pricing). Checked 23 November 2026.
15. [Railway — Deployment regions](https://docs.railway.com/reference/deployment-regions). Checked 23 November 2026.
16. [Fly.io — Pricing](https://docs.fly.io/about/pricing). Checked 23 November 2026.
