Production deployment
After creating a production build, launch the Node.js server that serves it.
Next.js 16+ · Command
Starts a previously built Next.js application in production mode. It supports selecting the directory, port, hostname, connection timeout, and optional CPU profiling.
Run this command after building a Next.js application to launch its production server. It serves the compiled output and accepts options such as the application directory, port, hostname, and keep-alive timeout.
next start [directory] [-p <port>] [-H <hostname>] [--keepAliveTimeout <milliseconds>] [--experimental-cpu-prof]| Name | Type | Description |
|---|---|---|
directory | string | Optional application directory; defaults to the current directory. |
port | number | Listening port; defaults to 3000 and can also come from PORT. |
hostname | string | Listening hostname; defaults to 0.0.0.0. |
keepAliveTimeout | number | Maximum inactive-connection wait time in milliseconds. |
Starts the Next.js production server.
next start to serve the application as a production server.-p or --port <port>.-H or --hostname <hostname>.--keepAliveTimeout <keepAliveTimeout>.--experimental-cpu-prof writes V8 CPU profiles to .next-profiles/ when the process exits.next build before next start; starting without a production build is unsupported.npm run build
npm run start -- --port 4000Builds the application and then starts the compiled production server on port 4000.
After creating a production build, launch the Node.js server that serves it.
Run the built application on a non-default port for local verification or infrastructure constraints.
Adjust inactive connection handling for a production server or enable CPU profiling during diagnosis.
next start do, and what must happen first?next start launches the application in production mode. The application must be compiled with next build before this command runs.
Follow-up: How would you change the listening port? Pass -p or --port, or set the PORT environment variable.
next start support?The command accepts an optional directory followed by options such as --port and --hostname. Without a directory, it starts the application from the current directory.
Follow-up: What is the default hostname? It is 0.0.0.0, unless overridden with -H or --hostname.
Use --keepAliveTimeout with a value in milliseconds to configure how long inactive connections remain open before closing. For example, next start --keepAliveTimeout 70000 sets 70,000 milliseconds.
Follow-up: What other operational profiling option is documented? --experimental-cpu-prof enables V8 CPU profiling and saves profiles under .next-profiles/ on exit.
next buildnext devnext CLI