# Deploy NestJS

NestJS is detected from your `package.json` and runs as a Node.js container on port `3000`. The [generated image](/platform/deployments/builds#dockerfiles-generated-or-your-own) runs your `build` script (Nest's TypeScript compile) and starts the compiled app on Node 22.

## Serve it

Listen on the routed [port](/create/build-settings#port), all interfaces:

```ts
const app = await NestFactory.create(AppModule);
await app.listen(process.env.PORT ?? 3000, '0.0.0.0');
```

## Configuration and database

`@nestjs/config` reads `process.env` - which is where [environment variables](/platform/environment-variables#build-time-and-runtime) arrive at runtime, per environment. Set `DATABASE_URL` from the [Credentials tab](/platform/databases/connect) for TypeORM, Prisma, or Mikro-ORM.

Run migrations at startup or from your laptop against the same endpoint - see [Connect from your laptop](/platform/databases/connect#connect-from-your-laptop).

## Scaling

Nest apps often carry DI-heavy startup - keep providers lazy where possible so [cold starts](/create/scaling#cold-starts) stay short, or set [min instances](/create/scaling#min-instances) to `1` on production.

## Related

- [Connect an app](/platform/databases/connect): DATABASE_URL, TLS, per-environment databases.
- [Builds](/platform/deployments/builds): The generated Node image, step by step.
- [Scaling](/create/scaling): Warm minimums and cold starts.
