Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

My Next.js app deployed to Vercel shows a 404 page not found

Error404: NOT_FOUND

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

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

Fix it fast

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

    1. 1A folder exists under app, but the URL for it returns 404 locally too.The route folder has no page fileFix
    2. 2Every 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. 3The 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. 4Vercel 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

What does the error look like?

  • 404: NOT_FOUND
  • The 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/blog

2Fix

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

Confirmed by nextjs.org

Did this fix it?

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

3Verify

Redeploy and open the production URL.

curl -I https://your-project.vercel.app/

Confirmed by vercel.com

Did this fix it?

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

2Fix

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 off

3Verify

Open the new deployment's build log and check that next build ran, then request a route.

curl -I https://your-project.vercel.app/blog

Confirmed by vercel.com

Did this fix it?

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 listed

2Fix

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

3Verify

Open the production domain or the latest deployment URL.

curl -I https://your-project.vercel.app/

Confirmed by vercel.com

Did this fix it?

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

Next step

Want this handled for good?

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