Search code examples
next.jsnext.js13custom-error-pages

Why I am getting 404 Page Not Found in my NextJS 13 app?


I have been learning Next.js 13. I have encountered an unusual error when I start the app for the first time. The pages are shown properly. But if I close it and reopen the application again, it starts showing a page not found.

My folder structure

My folder structure

My homepage page.tsx

My homepage page.tsx

Terminal

Terminal

Output + Console

Output + Console

I just ran the application just like any other normal app. I was expecting to see the contents of my page, but it's showing the page not found error.


Solution

  • That happens because you have the app directory in the root and in the src directory. You made a route in src/app/page.tsx but Next.js will not read your src if there is <ROOT>/app so it's not found.

    Remove the extra app directory