My Next.js app deployed to Vercel shows a 404 page not found
404: NOT_FOUNDShort answer
A 404 after a Vercel deploy usually means Vercel built or served the wrong thing. Check four places: the route has a page file, the project's Root Directory points at the app, the Framework Preset is Next.js with no Output Directory override, and the URL belongs to a deployment that still exists.
Fix it fast
1Find out which cause you have
Run a production build locally and request the failing path. If it also returns 404 locally, the route does not exist (cause 1). If it works locally, compare the project settings and the build log on Vercel (causes 2 to 4).
npx next build && npx next start curl -I http://localhost:3000/your-path2Match what you see, then jump to its fix
- 1
A folder exists under app, but the URL for it returns 404 locally too.The route folder has no page fileFix - 2
Every URL returns 404, and the repository has the app in a subfolder, for example a monorepo.The Root Directory does not point at the Next.js appFix - 3
The build succeeds but the site is empty or every route is 404. The settings show a preset such as Other, or a custom Output Directory.The Framework Preset or Output Directory is wrongFix - 4
Vercel shows NOT_FOUND for one deployment URL, while the production domain works.The URL points at a deployment that was deleted or does not existFix
- 1
What does the error look like?
404: NOT_FOUNDThe page works with next dev but not on the Vercel URL
Cause 1 of 4
The route folder has no page file
1Check
A folder defines a URL segment. The route only becomes publicly accessible when the folder holds a page file.
find app -name "page.*" | sort
ls app/blog2Fix
Add a page.tsx (or page.js) with a default export to the folder.
// app/blog/page.tsx
export default function Page() {
return <h1>Blog</h1>
}3Verify
Build locally and request the path again. It returns 200.
npx next build && npx next start
curl -I http://localhost:3000/blogConfirmed by nextjs.org
Cause 2 of 4
The Root Directory does not point at the Next.js app
1Check
Vercel builds from the Root Directory in Project Settings. If it is the repository top level while the app lives in front-end/, the build does not find the app.
git ls-files | grep -E "(^|/)package.json$"2Fix
In Project Settings, open Build and Deployment, scroll to Root Directory, enter the path of the app, save, and redeploy. Root Directory changes apply on the next deployment.
# example path to enter in Root Directory
front-end3Verify
Redeploy and open the production URL.
curl -I https://your-project.vercel.app/Confirmed by vercel.com
Cause 3 of 4
The Framework Preset or Output Directory is wrong
1Check
Vercel serves only what is in the Output Directory. With Other as the preset, it serves the public folder or the project root as plain files, which has no Next.js routes.
# in the dashboard: Settings > Build and Deployment > Framework Settings
# locally, the build output that Next.js produces:
ls .next | head2Fix
Under Framework Settings, set the Framework Preset to Next.js and switch off the Output Directory and Build Command overrides unless you have a reason for them. Then redeploy.
# Framework Preset: Next.js
# Build Command: Override off
# Output Directory: Override off3Verify
Open the new deployment's build log and check that next build ran, then request a route.
curl -I https://your-project.vercel.app/blogConfirmed by vercel.com
Cause 4 of 4
The URL points at a deployment that was deleted or does not exist
1Check
The NOT_FOUND error page lists the usual reasons: a typo or wrong path in the URL, a deleted deployment, a deployment that is unavailable because of problems in its logs, or missing permissions.
# in the dashboard: open the project, then Deployments, and compare the URL
# you were given with the deployments that are listed2Fix
Use the URL of a current deployment from the dashboard, check the deployment logs for errors, and confirm your role can open the project.
# Dashboard > Deployments > latest > Visit3Verify
Open the production domain or the latest deployment URL.
curl -I https://your-project.vercel.app/Confirmed by vercel.com
How do I stop it coming back?
- Run next build and next start before pushing, and request each new route.
- Keep Framework Preset on Next.js and leave overrides empty unless needed.
- Document the Root Directory in the repository readme for monorepos.
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
Web apps
AuthUserPoolException: Auth UserPool not configured in a Next.js app
Auth UserPool not configured
The error means an Amplify Auth call ran before Amplify.configure did.
3 causes, each with a fixWeb apps
Apollo Server rejects a request as a potential CSRF
HTTP 400 Bad Request from the GraphQL endpoint
Apollo Server's CSRF prevention is on by default.
3 causes, each with a fixWeb apps
Clerk cannot read its publishable key in a Next.js app
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY is undefined
Clerk reads NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY.
3 causes, each with a fixWeb apps
The shell cannot find create-next-app
command not found: create-next-app
create-next-app is not meant to be installed as a shell command.
2 causes, each with a fixWeb apps
ESLint fails with: Cannot find module 'next/babel'
ESLint stops on the first file with a Babel or parser error instead of listing lint results
next/babel is a Babel preset that ships inside the next package.
3 causes, each with a fixWeb apps
ESLint says an element in a list is missing its key prop
react/jsx-key
react/jsx-key fires when an element returned from map, Array.from or an array literal has no key.
3 causes, each with a fix