vercel/next.js · error · Error

You can not have a '_next' folder inside of your public…

Error message

You can not have a '_next' folder inside of your public folder. This conflicts with the internal '/_next' route. https://nextjs.org/docs/messages/public-next-folder-conflict

What it means

Error "You can not have a '_next' folder inside of your public folder. This conflicts with the internal '/_next' route. https://nextjs.org/docs/messages/public-next-folder-conflict" thrown in vercel/next.js.

Solutions

  1. Rename or remove the public/_next folder; it conflicts with Next.js internal routes.
Defensive patterns

Strategy: validation

When it happens

Trigger: A _next folder exists inside the public folder.

Common situations: Copying build output into public/, creating a public/_next that conflicts with the internal route.


AI-assisted analysis of vercel/next.js@996f957c06 (2026-08-19). Data as JSON: /api/errors/0ddd20a432471d92. Report an issue: GitHub.

Appendix: source

Thrown at packages/next/src/server/dev/next-dev-server.ts:564

  ): Promise<void> {
    await this.ready?.promise

    const { basePath } = this.nextConfig
    let originalPathname: string | null = null

    // TODO: see if we can remove this in the future
    if (basePath && pathHasPrefix(parsedUrl.pathname || '/', basePath)) {
      // strip basePath before handling dev bundles
      // If replace ends up replacing the full url it'll be `undefined`, meaning we have to default it to `/`
      originalPathname = parsedUrl.pathname
      parsedUrl.pathname = removePathPrefix(parsedUrl.pathname || '/', basePath)
    }

    const { pathname } = parsedUrl

    if (pathname!.startsWith('/_next')) {
      if (fs.existsSync(pathJoin(this.publicDir, '_next'))) {
        throw new Error(PUBLIC_DIR_MIDDLEWARE_CONFLICT)
      }
    }

    if (originalPathname) {
      // restore the path before continuing so that custom-routes can accurately determine
      // if they should match against the basePath or not
      parsedUrl.pathname = originalPathname
    }
    try {
      return await super.run(req, res, parsedUrl)
    } catch (error) {
      const err = getProperError(error)
      formatServerError(err)
      this.logErrorWithOriginalStack(err)
      if (!res.sent) {
        res.statusCode = 500
        try {
          return await this.renderError(err, req, res, pathname!, {

View on GitHub (pinned to 996f957c06)