Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

next start says it could not find a production build

ErrorCould not find a production build

Short 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.

  • Applies to Next.js 15, Next.js 16, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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"'
  2. 2Match what you see, then jump to its fix

    1. 1The .next folder is missing, or it only contains dev filesnext start ran without a next build before itFix
    2. 2Build succeeds in CI or in a build step, but the start command fails on the hostThe build ran somewhere else than the serverFix
    3. 3A custom build folder name exists on disk, but next start looks for .nextdistDir differs between build and startFix

What does the error look like?

  • Could not find a production build
  • next 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/null

2Fix

Run the build, then start the server. In package.json keep the standard scripts so the order is clear.

npm run build
npm run start

3Verify

The server prints its listening address and the home page answers.

curl -I http://localhost:3000

Confirmed by nextjs.org

Did this fix it?

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 | head

2Fix

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-app

3Verify

Run the start command from the deploy folder and confirm it boots.

npm run start

Confirmed by nextjs.org

Did this fix it?

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/null

2Fix

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 start

Confirmed by nextjs.org

Did this fix it?

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

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.