next start starts the application in production mode. The application must be compiled first with next build.
Options
string
The directory containing the Next.js application. Defaults to the current working directory.
number
default:"3000"
Port number to listen on. Can also be set via the
PORT environment variable.string
default:"0.0.0.0"
Hostname to bind the server to.
number
Maximum time in milliseconds to wait before closing inactive keep-alive connections. Important when deploying behind a load balancer.
boolean
Enable CPU profiling via V8’s inspector. Profiles are saved to
.next/cpu-profiles/ on process exit.boolean
Show all available options.
Environment variables at start time
Environment variables loaded bynext start depend on where they are defined:
NEXT_PUBLIC_* variables are inlined at build time and cannot be changed at start time. Server-only variables (without the NEXT_PUBLIC_ prefix) can be changed between builds if you read them at request time.
PORT cannot be set in .env files. The HTTP server starts before environment files are loaded. Pass PORT as a system environment variable or use the -p flag.Examples
Start on a custom port
Bind to a specific hostname
Configure keep-alive timeout for a load balancer
When deploying behind a load balancer (e.g. AWS ELB/ALB), set the keep-alive timeout to a value greater than the load balancer’s idle timeout to prevent connection termination errors:CPU profiling
start-main-*.cpuprofile in .next/cpu-profiles/. Open them in Chrome DevTools under the Performance tab.
Serving a standalone build
If you built withoutput: 'standalone', use the generated minimal server instead of next start:
PORT and HOSTNAME environment variables:
