NestJS environment variables in production

.env files are never uploaded to Reverhost. Here is how to set variables for NestJS, and when each one takes effect.

Last updated November 25, 2026

How NestJS reads variables

NestJS has no browser bundle of its own. Read variables with process.env or ConfigService. ConfigModule works without a .env file because .env files are never uploaded.

Set your variables

npx ezhst env set JWT_SECRET=change-me
npx ezhst env import .env
npx ezhst env list
npx ezhst redeploy

Variables apply on the next deploy or redeploy.

What Reverhost provides

VariableValueAvailable
PORT3000Build step and runtime
HOSTNAME0.0.0.0When the app runs

NODE_ENV=production comes from the ENV line in the Node.js Dockerfile template, and HOST is set only if your Dockerfile sets it.

Your own variables are runtime env in the container. During the build they exist only in a RUN step that mounts the appenv secret, like the build step in the template:

Dockerfile
RUN --mount=type=secret,id=appenv,target=/run/secrets/appenv sh -c 'set -a; . /run/secrets/appenv; set +a; npm run build'

Never pass secrets with ARG or ENV, because they end up in the image.

Common problems

See the NestJS hub for every NestJS guide, or free NestJS hosting for what is included.

Frequently asked questions

Are my .env files uploaded?

No. ezhst deploy skips every .env* file. Use ezhst env set or ezhst env import.

Start for free

Install the skill, choose Global or Local, then tell your agent to deploy. No credit card, no config files.

$npx ezhst skill install