next.js: Error was not caught DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document
Bug report
Following the tutorial first steps, expecting to see a 404 page when running npm run dev but seeing an empty screen with the following error in console:
localhost/:1 GET http://localhost:3000/ 404 (Not Found)
Navigated to http://localhost:3000/
react-dom.development.js:27773 Download the React DevTools for a better development experience: https://fb.me/react-devtools
index.js:1 Error was not caught DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
at initializeBuildWatcher (http://localhost:3000/_next/static/runtime/main.js?ts=1580234262737:6291:39)
at http://localhost:3000/_next/static/runtime/main.js?ts=1580234262737:7260:40
console.<computed> @ index.js:1
(anonymous) @ next-dev.js:6
Promise.catch (async)
(anonymous) @ next-dev.js:6
./node_modules/next/dist/client/next-dev.js @ next-dev.js:6
__webpack_require__ @ bootstrap:792
checkDeferredModules @ bootstrap:45
webpackJsonpCallback @ bootstrap:32
(anonymous) @ main.js?ts=1580234262737:1
on-demand-entries-utils.js:5 GET http://localhost:3000/ 404 (Not Found)
(anonymous) @ on-demand-entries-utils.js:5
handleMessage @ eventsource.js:1
on-demand-entries-utils.js:5 GET http://localhost:3000/ 404 (Not Found)
(anonymous) @ on-demand-entries-utils.js:5
handleMessage @ eventsource.js:1
To Reproduce
Chrome 80 which will be released in Feb has some important changes for 3rd party cookie policy: https://blog.chromium.org/2019/10/developers-get-ready-for-new.html https://web.dev/samesite-cookies-explained/
To reproduce this error on chrome 79, turn these two flags on:
chrome://flags/#cookies-without-same-site-must-be-secure chrome://flags/#same-site-by-default-cookies
Then follow the tutorial and see the blank page when starting the dev server
Expected behavior
To see a 404 page
Screenshots

System information
Next: 9.2.1 Node: v12.13.1 OS: Ubuntu 19.10 Chrome: Version 79.0.3945.130 (Official Build) (64-bit)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 18 (11 by maintainers)
There is a similar error with disabled
localStoragein general.When doing so for chrome see stack-overflow on how to do it. And using the described scenario of @rafaelalmeidatk the app will fail when accessing the page.
The problem for this specific case for me seems to be that the prerender-indicator is accessing the
localStoragewithout testing if it is enabled : https://github.com/zeit/next.js/blob/81fd704681fcac4d241e6f94bb45232ddc403e72/packages/next/client/dev/prerender-indicator.js#L43 https://github.com/zeit/next.js/blob/81fd704681fcac4d241e6f94bb45232ddc403e72/packages/next/client/dev/prerender-indicator.js#L74Not sure if this relates to the other issues.
@lfades the issue is present for all Storyblok backends. I run on newest stable version of NextJS and the issue just got introduced with FastRefresh
This issue still happens in the latest nextjs when behind an iframe.
@dohomi In that case please create a new issue with a reproduction that we can take a look at 🙏