vercel/next.js · critical
Could not find a production build in the '${this.distDir}' d
Error message
Could not find a production build in the '${this.distDir}' directory. Try building your app with 'next build' before starting the production server. https://nextjs.org/docs/messages/production-start-no-build-id What it means
Thrown by NextNodeServer.getBuildId() when the BUILD_ID file (this.distDir/BUILD_ID) cannot be read with an ENOENT (file-not-found) error. The production server reads BUILD_ID to identify which build it is serving; its absence means no build output exists in the configured distDir.
Source
Thrown at packages/next/src/server/next-server.ts:524
pathname,
this.distDir,
this.nextConfig.i18n?.locales,
this.enabledDirectories.app
)
}
protected getBuildId(): string {
const buildIdFile = join(
/* turbopackIgnore: true */ this.distDir,
BUILD_ID_FILE
)
try {
return fs
.readFileSync(/* turbopackIgnore: true */ buildIdFile, 'utf8')
.trim()
} catch (err: any) {
if (err.code === 'ENOENT') {
throw new Error(
`Could not find a production build in the '${this.distDir}' directory. Try building your app with 'next build' before starting the production server. https://nextjs.org/docs/messages/production-start-no-build-id`
)
}
throw err
}
}
protected getEnabledDirectories(dev: boolean): NextEnabledDirectories {
const dir = dev ? this.dir : this.serverDistDir
return {
app: findDir(dir, 'app') ? true : false,
pages: findDir(dir, 'pages') ? true : false,
}
}
protected sendRenderResult(View on GitHub (pinned to 0ae8c72462)
Solutions
- Run `next build` before `next start` so that <distDir>/BUILD_ID is generated.
- Verify `distDir` in next.config.js matches the directory the server is reading (default is `.next`).
- Confirm the build output directory is present in your deployment artifact (Docker image, server bundle) before starting the server.
- If using a custom server, ensure the `dir`/`distDir` passed to NextServer points at the built output.
Example fix
// before # only ran: next start // after # build first, then start next build && next start
Defensive patterns
Strategy: validation
Validate before calling
const fs = require('fs')
const path = require('path')
const distDir = '.next' // match next.config distDir
if (!fs.existsSync(path.join(distDir, 'BUILD_ID'))) {
throw new Error(`No build in ${distDir}. Run 'next build' first.`)
} Prevention
- Always run `next build` before `next start`; chain them in your start script.
- Verify the BUILD_ID file exists in your Docker image/deployment artifact before starting.
- Keep distDir consistent between build and start (don't change next.config.js between them).
- In CI, fail fast if the build step didn't produce BUILD_ID.
When it happens
Trigger: Running `next start` (or a production server) without ever running `next build`; setting a custom `distDir` in next.config.js so the server looks in a different directory than where the build wrote; deleting/clearing the .next directory after building; deploying only source without the built artifacts.
Common situations: CI/CD pipeline runs `next start` but skipped the build step; Docker image copies source but not the built .next folder; distDir was renamed in config but the server is pointed at the default .next; a fresh checkout where someone ran start instead of dev.
Related errors
- Could not find a production build in the '${opts.config.dist
- Failed to deploy project ${linkRes.stdout} ${linkRes.stderr}
- Manifest file is empty
- An error occurred while loading the instrumentation hook
- "next start" does not work with "output: export" configurati
AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06).
Data as JSON: /api/errors/c9816a3d4cb01480.
Report an issue: GitHub.