next start says it could not find a production build
Could not find a production buildShort answer
next start only serves a finished build, it does not create one. If the build folder is missing, the server stops with a 'could not find a production build' error. Run next build first, make sure the build step runs where the server runs, and check that distDir points to the same folder in both steps.
Fix it fast
1Find out which cause you have
Check whether the build folder exists in the directory where next start runs, and whether it holds a build or only development files.
ls -la .next cat package.json | grep -A6 '"scripts"'2Match what you see, then jump to its fix
- 1
The .next folder is missing, or it only contains dev filesnext start ran without a next build before itFix - 2
Build succeeds in CI or in a build step, but the start command fails on the hostThe build ran somewhere else than the serverFix - 3
A custom build folder name exists on disk, but next start looks for .nextdistDir differs between build and startFix
- 1
What does the error look like?
Could not find a production buildnext start fails before the server listens on any port
Cause 1 of 3
next start ran without a next build before it
1Check
In Next.js 16, next dev writes to .next/dev, not to the production build output. A project that has only ever run next dev has no production build.
ls .next .next/dev 2>/dev/null2Fix
Run the build, then start the server. In package.json keep the standard scripts so the order is clear.
npm run build
npm run start3Verify
The server prints its listening address and the home page answers.
curl -I http://localhost:3000Confirmed by nextjs.org
Cause 2 of 3
The build ran somewhere else than the server
1Check
Compare where the build output was created with where the process starts. If the deploy copies only source files, or only some folders, the build never reaches the server.
pwd
ls -la .next | head2Fix
Run next build in the same environment and folder that runs next start, or copy the whole build folder together with package.json and node_modules to the host. next start also accepts the project directory as an argument.
npm run build && npm run start
# or point start at a project directory:
npx next start ./my-app3Verify
Run the start command from the deploy folder and confirm it boots.
npm run startConfirmed by nextjs.org
Cause 3 of 3
distDir differs between build and start
1Check
A custom distDir in next.config makes next build write to that folder instead of .next. If the config is not loaded the same way when starting (different directory or config file), the server looks in the wrong place.
grep -n "distDir" next.config.*
ls -d .next build 2>/dev/null2Fix
Keep one distDir value in next.config and start the server from the directory that holds that config.
// next.config.js
module.exports = {
distDir: 'build',
}3Verify
Build again, then start from the same directory.
npm run build
npm run startConfirmed by nextjs.org
How do I stop it coming back?
- Keep the three standard scripts (dev, build, start) in package.json and use build then start in every deploy.
- On a host that builds for you, check that the build command is configured and ran in the deploy log.
- Do not delete .next after the build step.
- If you set distDir, set it once in next.config and never override it per environment.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
create-next-app keeps creating a TypeScript project
Would you like to use TypeScript? No / Yes
create-next-app now makes a TypeScript project by default.
2 causes, each with a fixBack end
Show a custom sign-in error in NextAuth without leaving the page
http://localhost:3000/api/auth/error?error=...
By default a failed NextAuth credentials sign-in navigates to the error page with the message in the URL.
3 causes, each with a fixBack end
Request body is rejected as too large in Next.js (1 MB default)
413 Payload Too Large
Next.js limits request bodies to 1 MB by default, in both Pages Router API routes and Server Actions.
3 causes, each with a fixBack end
Next.js server code cannot connect to its own API on 127.0.0.1
Error: connect ECONNREFUSED 127.0.0.1:3003
ECONNREFUSED means nothing was listening at that address and port when the server-side fetch ran.
2 causes, each with a fixBack end
next build stops with: Failed to collect page data for a route
Error: Failed to collect page data for /dashboard
Failed to collect page data for a route is the last line of a failed build, not the cause.
3 causes, each with a fixBack end
TypeError: Failed to parse URL when a Next.js server fetches its own API
TypeError: Failed to parse URL from undefined/api/test
Server code has no page address, so fetch('/api/test') cannot be turned into a full URL and throws Failed to parse URL.
3 causes, each with a fix