Skip to main content
Run anvil start to execute the production bundle generated by anvil build. The command spawns the bundle as a child Node.js process, inheriting stdio so logs appear in your terminal or platform’s log drain. This is the command you call in Dockerfile CMD entries, process manager configs, and deploy scripts.

Usage

anvil start [options]

Flags

-e, --entry <file>
string
default:"dist/server.mjs"
Path to the bundle produced by anvil build. If the file does not exist, anvil start prints an error and exits with code 1 — it will not attempt to build it automatically.
-p, --port <port>
number
Override the HTTP port. When provided, this value is forwarded to the child process as the PORT environment variable, taking precedence over any PORT already set in the environment. When omitted, the bundle falls back to PORT from the environment, then to 3000.

Port resolution order

The port used by the running server follows this precedence, from highest to lowest:
  1. --port <port> flag passed to anvil start
  2. PORT environment variable already set in the shell
  3. Default value of 3000 hardcoded in the generated bundle entry point

Example: basic deploy script

A typical deploy pipeline builds the project then starts it:
# Build the production artifact
anvil build

# Start the server
anvil start

Example: custom port

anvil start --port 8080

Example: custom bundle path

anvil start --entry build/app.mjs --port 8080

Example: using PORT from the environment

PORT=443 anvil start

Example: Docker

FROM node:20-slim
WORKDIR /app

COPY package*.json ./
RUN npm ci --omit=dev

COPY . .
RUN npx anvil build

EXPOSE 3000
CMD ["npx", "anvil", "start"]

Error: bundle not found

If you run anvil start before anvil build, you will see:
[anvil] /absolute/path/to/dist/server.mjs not found — run `anvil build` first
anvil start does not watch for file changes or restart on crashes. In production, wrap it with a process supervisor such as PM2, Docker restart policies, or your platform’s native process management to get automatic restarts.
For zero-downtime deploys, build the new bundle alongside the running server, then send a signal to swap. Because anvil start spawns a standard Node.js child process, all normal graceful-shutdown patterns (SIGTERM handlers, drain logic) apply.