DockHosting Docs
Deploying

NestJS

Deploy a NestJS API on DockHosting — build, port binding, and databases.

NestJS is detected the same way as any Node.js project — from package.json — and built with the same pipeline described in Deploying → Node.js. This page covers what's specific to Nest.

Build and start

DockHosting runs your build script (typically nest build, compiling to dist/) and then your start script (typically node dist/main.js or nest start --prod). Make sure both exist in package.json and actually match how your project is structured — a start script pointing at a stale dist/ path is a common cause of a container that builds fine but crashes on boot.

Listening on the right port and host

Nest's default main.ts often has app.listen(3000) hard-coded. Read the port from the environment instead, and bind to all interfaces:

await app.listen(process.env.PORT ?? 3000, '0.0.0.0');

A Nest app that only listens on localhost is unreachable from outside its own container — this produces a readiness timeout that looks like a hang, not an obvious "wrong host" error.

Config module

If you use @nestjs/config, environment variables set in your project's DockHosting settings are picked up the normal way — ConfigService reads from process.env under the hood, no extra wiring needed. See Environment variables.

Databases

TypeORM, Prisma, and Mongoose all accept a connection string — the one DockHosting injects when you attach a database to the project works directly in each.

Microservices and workers

A Nest microservice or a standalone worker that doesn't expose an HTTP port needs scale-to-zero awareness the same way any long-running process does — see the note in Deploying → Node.js.

On this page