Error: <Html> should not be imported outside of pages/_document.
Unanswered
Dwarf Crocodile posted this in #help-forum
Dwarf CrocodileOP
Im running a Next.JS application through Coolify and i've started getting this error but the commit that caused it only changed this
in an onSubmit handler and it all compiles fine locally and works in my dev environment but something makes it error on my server. And no there are no references to <Html> anywhere in the code. Repo is https://github.com/dinkelspiel/medialog
2025-Oct-09 10:57:47.749003
#23 34.80 info - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/app/api-reference/config/eslint#disabling-rules
2025-Oct-09 10:57:47.749003
#23 39.31 Collecting page data ...
2025-Oct-09 10:57:47.749003
#23 42.88 Generating static pages (0/15) ...
2025-Oct-09 10:57:47.749003
#23 43.37 Error: <Html> should not be imported outside of pages/_document.
2025-Oct-09 10:57:47.749003
#23 43.37 Read more: https://nextjs.org/docs/messages/no-document-import-in-page
2025-Oct-09 10:57:47.749003
#23 43.37 at x (.next/server/chunks/215.js:6:1351)
2025-Oct-09 10:57:47.749003
#23 43.37 Error occurred prerendering page "/404". Read more: https://nextjs.org/docs/messages/prerender-error
2025-Oct-09 10:57:47.749003
#23 43.37 Error: <Html> should not be imported outside of pages/_document.
2025-Oct-09 10:57:47.749003
#23 43.37 Read more: https://nextjs.org/docs/messages/no-document-import-in-page
2025-Oct-09 10:57:47.749003
#23 43.37 at x (.next/server/chunks/215.js:6:1351)
2025-Oct-09 10:57:47.749003
#23 43.37 Export encountered an error on /_error: /404, exiting the build.
2025-Oct-09 10:57:47.749003
#23 43.52 ⨯ Next.js build worker exited with code: 1 and signal: null
2025-Oct-09 10:57:47.749003
#23 43.55 ELIFECYCLE Command failed with exit code 1.
2025-Oct-09 10:57:47.749003
#23 ERROR: process "/bin/bash --login -c pnpm build" did not complete successfully: exit code: 1
2025-Oct-09 10:57:47.749003
------
2025-Oct-09 10:57:47.749003
43.37 Error: <Html> should not be imported outside of pages/_document.
2025-Oct-09 10:57:47.749003
43.37 Read more: https://nextjs.org/docs/messages/no-document-import-in-page
2025-Oct-09 10:57:47.749003
43.37 at x (.next/server/chunks/215.js:6:1351)
2025-Oct-09 10:57:47.749003
43.37 Error occurred prerendering page "/404". Read more: https://nextjs.org/docs/messages/prerender-error
2025-Oct-09 10:57:47.749003
43.37 Error: <Html> should not be imported outside of pages/_document.
2025-Oct-09 10:57:47.749003
43.37 Read more: https://nextjs.org/docs/messages/no-document-import-in-page
2025-Oct-09 10:57:47.749003
43.37 at x (.next/server/chunks/215.js:6:1351)
2025-Oct-09 10:57:47.749003
43.37 Export encountered an error on /_error: /404, exiting the build.
2025-Oct-09 10:57:47.749003
43.52 ⨯ Next.js build worker exited with code: 1 and signal: null
2025-Oct-09 10:57:47.749003
43.55 ELIFECYCLE Command failed with exit code 1.
setBody('');
setTitle('');
setLabel('bug');
setOpen(false);in an onSubmit handler and it all compiles fine locally and works in my dev environment but something makes it error on my server. And no there are no references to <Html> anywhere in the code. Repo is https://github.com/dinkelspiel/medialog
2025-Oct-09 10:57:47.749003
#23 34.80 info - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/app/api-reference/config/eslint#disabling-rules
2025-Oct-09 10:57:47.749003
#23 39.31 Collecting page data ...
2025-Oct-09 10:57:47.749003
#23 42.88 Generating static pages (0/15) ...
2025-Oct-09 10:57:47.749003
#23 43.37 Error: <Html> should not be imported outside of pages/_document.
2025-Oct-09 10:57:47.749003
#23 43.37 Read more: https://nextjs.org/docs/messages/no-document-import-in-page
2025-Oct-09 10:57:47.749003
#23 43.37 at x (.next/server/chunks/215.js:6:1351)
2025-Oct-09 10:57:47.749003
#23 43.37 Error occurred prerendering page "/404". Read more: https://nextjs.org/docs/messages/prerender-error
2025-Oct-09 10:57:47.749003
#23 43.37 Error: <Html> should not be imported outside of pages/_document.
2025-Oct-09 10:57:47.749003
#23 43.37 Read more: https://nextjs.org/docs/messages/no-document-import-in-page
2025-Oct-09 10:57:47.749003
#23 43.37 at x (.next/server/chunks/215.js:6:1351)
2025-Oct-09 10:57:47.749003
#23 43.37 Export encountered an error on /_error: /404, exiting the build.
2025-Oct-09 10:57:47.749003
#23 43.52 ⨯ Next.js build worker exited with code: 1 and signal: null
2025-Oct-09 10:57:47.749003
#23 43.55 ELIFECYCLE Command failed with exit code 1.
2025-Oct-09 10:57:47.749003
#23 ERROR: process "/bin/bash --login -c pnpm build" did not complete successfully: exit code: 1
2025-Oct-09 10:57:47.749003
------
2025-Oct-09 10:57:47.749003
[19/19] RUN pnpm build:2025-Oct-09 10:57:47.749003
43.37 Error: <Html> should not be imported outside of pages/_document.
2025-Oct-09 10:57:47.749003
43.37 Read more: https://nextjs.org/docs/messages/no-document-import-in-page
2025-Oct-09 10:57:47.749003
43.37 at x (.next/server/chunks/215.js:6:1351)
2025-Oct-09 10:57:47.749003
43.37 Error occurred prerendering page "/404". Read more: https://nextjs.org/docs/messages/prerender-error
2025-Oct-09 10:57:47.749003
43.37 Error: <Html> should not be imported outside of pages/_document.
2025-Oct-09 10:57:47.749003
43.37 Read more: https://nextjs.org/docs/messages/no-document-import-in-page
2025-Oct-09 10:57:47.749003
43.37 at x (.next/server/chunks/215.js:6:1351)
2025-Oct-09 10:57:47.749003
43.37 Export encountered an error on /_error: /404, exiting the build.
2025-Oct-09 10:57:47.749003
43.52 ⨯ Next.js build worker exited with code: 1 and signal: null
2025-Oct-09 10:57:47.749003
43.55 ELIFECYCLE Command failed with exit code 1.
1 Reply
Northeast Congo Lion
I am seeing something similar.... stuff is just broken from last night. Weird coincidence