Hello, I have a problem with deploying my NextJS site.
I run a deploy, and I works totally fine and the site is live. Then I go to the site and get a “Page Not Found”-message.
When I download the build files it seems like it is just hosting all the files (within same folders) from Github. I have tried to go to the domain/pages/index.js and it works and I get the code.
The domain is
The build output:
8:06:33 PM: Executing user command: npm run build
8:06:34 PM: > firstname.lastname@example.org build /opt/build/repo
8:06:34 PM: > next build
8:06:34 PM: Browserslist: caniuse-lite is outdated. Please run next command
8:06:34 PM: Warning: No build cache found. Please configure build caching for faster rebuilds. Read more: No Cache Detected | Next.js
8:06:34 PM: Creating an optimized production build…
8:06:58 PM: Compiled successfully.
8:06:58 PM: Automatically optimizing pages…
8:07:00 PM: Page Size First Load JS
8:07:00 PM: ┌ ○ / 2.58 kB 233 kB
8:07:00 PM: ├ └ css/77c671b1533bce25839c.css 660 B
8:07:00 PM: ├ /_app 291 B 57.6 kB
8:07:00 PM: ├ ○ /404 2.58 kB 60.2 kB
8:07:00 PM: ├ ○ /registrer 8.07 kB 239 kB
8:07:00 PM: ├ └ css/d5b7fdd275e54fcbdfb4.css 692 B
8:07:00 PM: └ λ /sok 1.52 kB 232 kB
8:07:00 PM: └ css/ea6b46d0be8e614bce2f.css 676 B
8:07:00 PM: + First Load JS shared by all 57.6 kB
8:07:00 PM: ├ static/pages/_app.js 291 B
8:07:00 PM: ├ chunks/commons.db9b5a.js 10.5 kB
8:07:00 PM: ├ chunks/framework.8d738c.js 40.3 kB
8:07:00 PM: ├ runtime/main.e9b490.js 5.85 kB
8:07:00 PM: ├ runtime/webpack.b65cab.js 746 B
8:07:00 PM: └ css/498d61218e435377339b.css 239 B
8:07:00 PM: λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
8:07:00 PM: ○ (Static) automatically rendered as static HTML (uses no initial props)
8:07:00 PM: ● (SSG) automatically generated as static HTML + JSON (uses getStaticProps)
8:07:00 PM: Skipping functions preparation step: no functions directory set
8:07:00 PM: Caching artifacts
8:07:00 PM: Started saving node modules
8:07:00 PM: Finished saving node modules
8:07:00 PM: Started saving build plugins
8:07:00 PM: Finished saving build plugins
8:07:00 PM: Started saving pip cache
8:07:07 PM: Finished saving pip cache
8:07:07 PM: Started saving emacs cask dependencies
8:07:07 PM: Finished saving emacs cask dependencies
8:07:07 PM: Started saving maven dependencies
8:07:07 PM: Finished saving maven dependencies
8:07:07 PM: Started saving boot dependencies
8:07:07 PM: Finished saving boot dependencies
8:07:07 PM: Started saving go dependencies
8:07:07 PM: Finished saving go dependencies
8:07:10 PM: Creating deploy upload records
8:07:10 PM: Build script success
8:07:10 PM: Starting to deploy site from ‘.’
8:07:10 PM: Creating deploy tree
8:07:11 PM: Starting post processing
8:07:11 PM: 0 new files to upload
8:07:11 PM: 0 new functions to upload
8:07:11 PM: Post processing done
8:07:11 PM: Site is live
8:07:58 PM: Finished processing build request in 1m49.579972784s
Did you see this guide yet? This is the best place to start for “Page Not Found” issues.
Last reviewed by Netlify Support - August, 2023
Netlify attempts to lookup a file based on several xor filters, and when all of these fail, we end up serving a 404 page. For example, a request made to /example/ would check /example/index.html, /example.html, /example/home.html and several other combinations (not necessarily in the same order) before hitting the 404. However, in case you were not expecting a 404 at a particular URL, you might be interested in finding out the reason and potentia…
If you are still seeing issues after following the troubleshooting steps in this guide, please let us know!
Hi, thanks for answer!
I have readed a lot at that page, but didnt find any answer.
But, I have a theory. I think I cant server the page with Netlify because I use
recent blog post can give you a couple of pointers?
Out of interest – what happens if you change the build command to
npm run build && npm run export?
I’m having the very same issue.
My web app was building alright and being exported correctly until I added fallback: true to some of my blog pages and this config generates an SSG instead of a purely static web site. SSGs can not be exported, so there isn’t an “out/” folder with an index file that can be served.
Are there any workarounds to this?
Are there any workarounds to this?
@darksoulsong, I know SSG as meaning “Static Site Generator”:
Is it possible you mean that the build generates code which does server-side rendering (SSR) and not SSG? (If not, what does SSG stand for?)
If you are trying to due SSR at Netlify first please read this:
Last reviewed by Netlify Support on December 2022
How do I run a server/database at Netlify?
We often get questions about how to run a specific backend server or database at Netlify. Examples of these types of questions include:
How to I get my node HTTP listener to respond to requests?
How do I start Mongo/MySQL/<insert-some-database-here> running on the server?
How can I SSH into my website?
We are here today to answer these questions - and the answer is: you can’t!
What do you m…
That guide explains why SSR doesn’t work “out of the box” at Netlify. The following blog post, however, gives examples how it can be done using Functions:
If there are other questions, please let us know.
Hello Luke, sorry for keeping you waiting, I just had the time to answer now.
I’m referring to NextJS’s fallback feature on the newer versions. There are two new functions,
getStaticPaths with the mandatory
fallback prop, which basically displays a 404 page on nonexistent content on
false or tries to generate the pages dynamically on
true.I’m not certain if NextJS uses SSR in the backgrounds to make this work.
I’ve been told that
Netlify cannot handle dynamic sites, only static ones, so this is something I’d like to confirm with you guys.
@darksoulsong, based on that I’m almost certain that the dynamic
fallback: true setting is SSR. So,
fallback will need to be “
false” for Netlify.
That or some variation of the
solution above will be required (where serverless functions are used for the SSR).