Skip to content

Node.js and Bun backends

Deploy a NestJS app on Enzonic

Deploy builds a NestJS app with nest build and starts node dist/main.js directly (nest start would need the CLI and recompile at runtime). The app runs as a long-lived server, so WebSockets, queues and scheduled jobs inside it keep working.

At a glance

What Enzonic Deploy does with a NestJS project when you connect it. You can override any of it in the project settings.

Language
TypeScript
Detected from
@nestjs/core in dependencies
Build command
nest build
Output
dist
Runs as
Server

Dependencies install with the package manager your lockfile names: npm ci, pnpm install --frozen-lockfile, yarn install --immutable (Berry) or --frozen-lockfile, or bun install --frozen-lockfile. Node.js 18, 20, 22 and 24 are available. Deploy reads engines.node in package.json, then .nvmrc or .node-version, and uses Node.js 22 when nothing pins a version.

How it runs

  • Server

    Always: node dist/main.js, listening on the PORT variable.

Deploy NestJS step by step

  1. 1Make main.ts listen on process.env.PORT and 0.0.0.0.
  2. 2Connect the repository and deploy.
src/main.ts
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  await app.listen(process.env.PORT ?? 3000, '0.0.0.0');
}
bootstrap();

Connect a database to NestJS

Create a database on Enzonic Databases (or from the project's settings) and its connection string is added to the project's environment variables. This example uses PostgreSQL.

src/app.module.ts
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';

@Module({
  imports: [
    TypeOrmModule.forRoot({
      type: 'postgres',
      url: process.env.DATABASE_URL,
      ssl: true,
      autoLoadEntities: true,
    }),
  ],
})
export class AppModule {}

Postgres projects get two variables: DATABASE_URL through the connection pooler for the app, and DATABASE_URL_UNPOOLED for migrations.

PostgreSQL on Enzonic DatabasesEvery database engine

Things to know

  • A server that listens on a fixed port or on localhost only is not reachable: always use PORT and 0.0.0.0.
  • On Free, servers sleep after 15 idle minutes; in-process cron jobs pause with them. Paid plans keep servers always on.

Plan limits that matter here

From the live plan data. Every plan includes previews for each branch, instant rollback, environment variables and logs.

Plan limits that matter for NestJS
LimitFreePro
Build minutes3,000/mo, 1 concurrent10,000/mo, 3 concurrent
Servers1 instance, 512 MB, sleeps after 15 min idle3 always-on, 2 GB
Bandwidth150 GB/mo2 TB/mo

Compare every plan

Ship your NestJS project tonight

Connect the repository and the build settings fill themselves in. Free plan, no card.

Start free