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.
By Livops team, the people who build and run LivopsUpdated
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.
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
- Push the repository the Nest CLI made:
package.jsonwithbuild,startandstart:prodscripts, andsrc/main.tslistening onprocess.env.PORT. In the cabinet, click New project and choose the repository, or upload the folder as a.zip. - Under Databases, add PostgreSQL.
DATABASE_URLand thePG*variables are written into the service by themselves. - Put your own keys under Variables, marked as secret where they are secrets, and
NODE_ENV=productionif your code reads it. - Deploy. The log shows the install, the build and the start, and the app gets a
<name>.livops.appaddress with HTTPS.
What Livops reads from the repository:
- The type.
@nestjs/coreamong the runtime dependencies, not only indevDependencies, makes it a Node server, and@nestjs/platform-expressor@nestjs/platform-fastifymakes it a web app with an address. - Build.
npm run build, whenpackage.jsonhas a build script; for a Nest project that isnest build. - Start.
npm run start. Whenstartis a development command —nest start,nodemon,--watch,ts-node-dev,tsx watch— and astart:prodscript exists,npm run start:prodruns instead, which the Nest CLI writes asnode dist/main. Astart:prodthat runspm2is not used:pm2 startputs the app in the background and returns. - Prisma. With
prismaamong the packages andprisma/schema.prismain the repository,prisma generateruns before the build unless one of your install or build scripts already runs it. With migrations inprisma/migrationsand a database connected (DATABASE_URLset),prisma migrate deployruns before every start, unless the start already runs it. A failed migration does not stop the start; the log saysLivops: migrate failed, starting anyway. - TypeORM. Nothing is run for you. Use
migrationsRunas 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:
{
"kind": "web",
"build": "npm run build",
"start": "node dist/main.js",
"healthPath": "/health",
"memory": 512
}
When the app runs:
PORTis 3000 unless you change it, and a new version has a minute to answer on it. WithhealthPath, that path is what Livops checks to know the app is alive — write it with the global prefix unless you excluded the route,/api/healthfor the main.ts above without itsexclude.- 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=5inDATABASE_URL; on Prisma 7,max: 5in the@prisma/adapter-pgoptions, which default to 10. Keep TypeORM’s pool as small. - Memory is a tier of 256, 512, 1024 or 2048 MiB, set with
memoryinlivops.jsonwhen 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 saysKilledor exit code 137. - Files written to
/app/data(theDATA_DIRvariable) survive restarts and deploys; the code folder is read-only and/tmpis 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 for plans, which give more credits than they cost, Databases for sizes and connection limits, and Frameworks and livops.json 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
- NestJS — First steps (docs.nestjs.com). Checked .
- NestJS — Deployment (docs.nestjs.com). Checked .
- NestJS — Global prefix (docs.nestjs.com). Checked .
- NestJS — Health checks (Terminus) (docs.nestjs.com). Checked .
- NestJS — Lifecycle events (docs.nestjs.com). Checked .
- NestJS — TypeORM (docs.nestjs.com). Checked .
- Prisma — Development and production (prisma.io). Checked .
- Node.js — net, server.listen() (nodejs.org). Checked .
- PM2 — Startup script (pm2.keymetrics.io). Checked .
- PM2 — Cluster mode (pm2.keymetrics.io). Checked .
- SmartCloud — VDS plans (smartcloud.uz). Checked .
- Render — Pricing (render.com). Checked .
- Render — Deploy for free (render.com). Checked .
- Railway — Pricing (railway.com). Checked .
- Railway — Deployment regions (docs.railway.com). Checked .
- Fly.io — Pricing (docs.fly.io). Checked .
Put your project online today
Connect GitHub or drop a folder. No card is asked for.
Deploy your NestJS appRelated
- Node.js hosting in 2026: how to deploy an Express appA Node.js server in production needs one long-running process that listens on the port it is given, restarts when it crashes and exits cleanly on SIGTERM. On Livops you push a repository with package.json and it runs as a web app for 39 credits a month (39,000 so'm). Here is what Node needs, and how a VPS, Render, Railway, Fly.io, DigitalOcean and Heroku compare.
- Managed PostgreSQL hosting in 2026: the options comparedA production PostgreSQL needs backups you can restore, a connection limit your app stays under, the app in the same region, and a supported version. On Livops a PostgreSQL 15, 16 or 17 database runs inside your project, its DATABASE_URL is written into your services, and it is backed up every night; 500 MB is free, one per team, and 1 GB is 9 credits a month. Here is how Neon, Supabase, Render, Railway and a VPS compare.
- Docker hosting: how to deploy a Docker container or a DockerfileTo host a container you need a host that builds or pulls the image, starts its CMD, sends traffic to the port it listens on and stops it with SIGTERM. On Livops a Dockerfile at the root of the repository is built on Livops's servers and runs for 39 credits a month (39,000 so'm); a public image from Docker Hub, GHCR or Quay runs without a build. Here is what a container needs, and how a VPS, Render, Railway, Fly.io, DigitalOcean and Heroku compare.
- ECONNREFUSED / Connection refused: why the app cannot reach its database after deployNothing was listening at the address your app tried. When the address is 127.0.0.1 or localhost, the app never read the database's real address: DATABASE_URL is not set, is not read, or is read during a build that has no database. Attach the database, read DATABASE_URL (or REDIS_URL, MYSQL_URL) at runtime, run migrations before the start rather than in the build, and keep the connection pool under the server's limit.
- npm ERR! code 1: why the build failed with exit code 1npm ERR! code 1 (npm error code 1 in newer npm) only says that a script npm ran exited with code 1. The real error is printed above it: usually a compile or type error, a lockfile out of sync with package.json, or a dependency whose install script failed. Find the first error line above code 1, fix that, and the build passes.
- App not listening on $PORT: why the health check failed after deployThe platform started your app, tried the port it gave it, and nothing answered in time. Almost always the app listens on its own fixed port instead of the PORT variable, listens on localhost (127.0.0.1) instead of 0.0.0.0, or crashed or was still starting when the check gave up. Listen on 0.0.0.0 and the port in PORT, and it passes.