gatsby: Error loading a result for the page query in "/404.html". Query was not run and Page not found /404.html

Description

When using gatsby develop with a theme, the following error is printed in the terminal after a page is loaded in the browser:

Error loading a result for the page query in "/404.html". Query was not run and
Page not found /404.html

Steps to reproduce

  • gatsby new my-blog gatsbyjs/gatsby-starter-blog-theme
  • cd my-blog
  • gatsby develop
  • browse to http://localhost:8000
  • check the terminal to see this message:
Error loading a result for the page query in "/404.html". Query was not run and no cached result was
Page not found /404.html
  • This message will be printed to the terminal every time the page is refreshed.

There’s also a repro available at https://github.com/polishedwp/gatsby-starter-theme-eclectic courtesy of @polishedwp

Expected result

The Error loading a result for the page query… message should not appear in the terminal.

Actual result

The message appears.

Environment


  System:
    OS: macOS 10.14.5
    CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.16.0 - ~/.nvm/versions/node/v10.16.0/bin/node
    Yarn: 1.16.0 - /usr/local/bin/yarn
    npm: 6.9.0 - ~/.nvm/versions/node/v10.16.0/bin/npm
  Languages:
    Python: 3.5.3 - /Users/mike/.pyenv/shims/python
  Browsers:
    Chrome: 75.0.3770.100
    Firefox: 67.0.4
    Safari: 12.1.1
  npmPackages:
    gatsby: ^2.13.21 => 2.13.21 
    gatsby-theme-blog: ^1.0.0 => 1.0.0 
  npmGlobalPackages:
    gatsby-cli: 2.7.7
    gatsby-dev-cli: 2.4.19
    gatsby: 2.8.8

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 7
  • Comments: 23 (9 by maintainers)

Commits related to this issue

Most upvoted comments

I’m also getting this (or a very similar) error on gatsby build independently of themes:

ERROR ENOENT: no such file or directory, open '/<project-root>/public/page-data/404.html/page-data.json'

Running rm -r .cache solves the problem until the next build.

For me the error persists. Running gatsby build still crashes with

ERROR #95313

Building static HTML failed for path “/404.html”

See our docs page for more info on this error: https://gatsby.dev/debug-html

Error: ENOENT: no such file or directory, open ‘./public/page-data/404.html/page-data.json’

  • render-page.js:547 Module…/.cache/static-entry.js.webpack_exports.default

As mentioned above, if I delete the cache, rm -r .cache, it builds fine but only once.

Hey peepz, don’t know if that helps someone, but I had the same Error loading a result for the page query in "/404.html", And that’s with Gatsby v4. My solution was to run gatsby clean and then to run gatsby build again.

Though everything works as it should, I’m getting the same error when navigating pages I’m routing with @reach/router and gatsby-plugin-create-client-paths My console:

Error loading a result for the page query in "/authentication/navigate". Query was not run and no cached result was found.
Page not found /authentication/navigate
Error loading a result for the page query in "/authentication/login". Query was not run and no cached result was found.
Page not found /authentication/login

gatsby-config.js:

...
{
  resolve: `gatsby-plugin-create-client-paths`,
  options: {
  prefixes: [`/confirm-email/*`, `/authentication/*`],
},
...

My pages/authentication/index.js component:

...
const AuthenticationIndex = () => {
  return (
    <Layout>
      <div className="authentication-container">
        <Router>
          <Navigator path="authentication/navigate" />
          <AuthenticationContainer path="authentication" />
          <LoginFormContainer path="authentication/login" />
          <RegistrationFormContainer path="authentication/signup" />
          <PasswordResetFormContainer path="authentication/password-reset" />
          <PasswordResetConfirmFormContainer path="authentication/password-reset/confirm/:uid/:token" />
        </Router>
      </div>
    </Layout>
  )
}
...

my problem is not solve in running gatsby clean. I am using "gatsby": "^4.11.2",

Same issue with client-only paths (‘/app/*’) using gatsby-plugin-create-client-paths@2.1.3

Note that running gatsby build && gatsby serve will show the same error as error Error: ENOENT: no such file or directory, stat '/path/to/my/project/hello-world/public/404.html'

hit the same issue here… anyone has a solution?

Not sure if anyone is still monitoring this thread, but I am occasionally getting this same (similar, but different) error.

As others have said, stopping gatsby develop and then rm -rf .cache fixes, but about every 3rd or 4th time of running gatsby develop I get this error, and if I don’t catch it, it breaks production build pipelines…

Did anyone ever find a (more perm) solution for this situation?

edit nvm, I see that this issue is closed (after I posted), I’ll see if I can find a more active/recent ticket).