nextjs - 💡(How to fix) Fix not-found.js is always rendered [3 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#87174Fetched 2026-04-08 02:07:37
View on GitHub
Comments
3
Participants
3
Timeline
11
Reactions
0
Author
Timeline (top)
commented ×3labeled ×2subscribed ×2closed ×1

Code Example

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 32469
  Available CPU cores: 20
Binaries:
  Node: 22.18.0
  npm: 11.1.0
  Yarn: 1.22.22
  pnpm: 9.15.4
Relevant Packages:
  next: 16.0.10 // Latest available version is detected (16.0.10).
  eslint-config-next: N/A
  react: 19.2.1
  react-dom: 19.2.1
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/jorrit/nextjs-test-not-found

To Reproduce

  1. Clone https://github.com/jorrit/nextjs-test-not-found
  2. npm ci, npm run dev
  3. Visit http://localhost:3000
  4. Notice that NotFound is rendered is written to the server console

Current vs. Expected behavior

Currently, the not-found.tsx file is rendered for every page view. I want to use this file to run a query to see if a redirect exists for the current URL. This is not possible when this component is rendered on every pageview.

Also, it seems like a waste of effort.

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 32469
  Available CPU cores: 20
Binaries:
  Node: 22.18.0
  npm: 11.1.0
  Yarn: 1.22.22
  pnpm: 9.15.4
Relevant Packages:
  next: 16.0.10 // Latest available version is detected (16.0.10).
  eslint-config-next: N/A
  react: 19.2.1
  react-dom: 19.2.1
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Not Found

Which stage(s) are affected? (Select all that apply)

next start (local)

Additional context

No response

extent analysis

TL;DR

Review the Next.js configuration and routing setup to ensure that the not-found.tsx file is only rendered when a page is not found, rather than on every page view.

Guidance

  • Verify that the not-found.tsx file is correctly configured as a catch-all route in Next.js, and that it's not being imported or rendered unnecessarily in other components.
  • Check the next.config.js file for any custom routing configurations that might be causing the not-found.tsx file to be rendered on every page view.
  • Review the pages directory structure to ensure that it's correctly set up and that there are no unnecessary re-exports or imports that could be causing the issue.
  • Consider adding logging or debugging statements to the not-found.tsx file to determine why it's being rendered on every page view.

Example

No specific code example is provided, as the issue seems to be related to the overall configuration and setup of the Next.js project.

Notes

The issue might be related to a misunderstanding of how Next.js handles routing and catch-all routes. Without more information about the project's configuration and code, it's difficult to provide a more specific solution.

Recommendation

Apply workaround: Review and adjust the Next.js configuration and routing setup to ensure that the not-found.tsx file is only rendered when a page is not found. This will likely involve updating the next.config.js file and reviewing the project's directory structure and imports.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING