Gatsby: Gatsby Build, Serve can't find Resource '/'

Created on 1 Feb 2019  路  5Comments  路  Source: gatsbyjs/gatsby

Steps to reproduce

gatsby --version
2.4.8
gatsby new my-site
// success, no errors

cd my-site
gatsby build
// success, no errors

gatsby serve
// info gatsby serve running at: http://localhost:9000/

Go to http://localhost:9000/ and the page is blank (white), check chrome console...

Expected result

The landing page should load. This works if I run gatsby develop and go to localhost:8000. No errors in chrome console.

Actual result

When you run gatsby serve and go to localhost:9000, page loads blank (white), so check chrome console:

Failed to load resource: the server responded with a status of 404 (Not Found)
app-05873d9c14927591ecdc.js:1 Error: Missing resources for /
    at t.n.render (app-05873d9c14927591ecdc.js:1)
    at ci (app-05873d9c14927591ecdc.js:1)
    at ui (app-05873d9c14927591ecdc.js:1)
    at pi (app-05873d9c14927591ecdc.js:1)
    at Qi (app-05873d9c14927591ecdc.js:1)
    at Yi (app-05873d9c14927591ecdc.js:1)
    at Ma (app-05873d9c14927591ecdc.js:1)
    at Na (app-05873d9c14927591ecdc.js:1)
    at Pa (app-05873d9c14927591ecdc.js:1)
    at ta (app-05873d9c14927591ecdc.js:1)

Environment

gatsby info --clipboard

  System:
    OS: Linux 4.15 Pop!_OS 18.04 LTS
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Shell: 4.4.19 - /bin/bash
  Binaries:
    Node: 10.13.0 - ~/.nvm/versions/node/v10.13.0/bin/node
    npm: 6.4.1 - ~/.nvm/versions/node/v10.13.0/bin/npm
  Languages:
    Python: 2.7.15 - /usr/bin/python
  Browsers:
    Chrome: 70.0.3538.102
    Firefox: 63.0
  npmPackages:
    gatsby: ^2.0.107 => 2.0.107 
    gatsby-image: ^2.0.29 => 2.0.29 
    gatsby-plugin-manifest: ^2.0.16 => 2.0.16 
    gatsby-plugin-offline: ^2.0.22 => 2.0.22 
    gatsby-plugin-react-helmet: ^3.0.5 => 3.0.5 
    gatsby-plugin-sharp: ^2.0.19 => 2.0.19 
    gatsby-source-filesystem: ^2.0.19 => 2.0.19 
    gatsby-transformer-sharp: ^2.1.13 => 2.1.13 
  npmGlobalPackages:
    gatsby-cli: 2.4.8

Other

  • When I do ls public it shows a bunch of file and directories, including an index.html.
  • Is there something simple I'm missing here?
  • Some arguments to pass to the build or serve commands?
  • I was following this: https://www.gatsbyjs.org/docs/gatsby-cli/
  • does this work for you guys? takes a minute if you could test it, just a simple build and serve, I did not modify any code.
  • certain branch to try? Previous version to could try, maybe will work?
  • I'm on Ubuntu 18.04 and have run prod builds of React and Angular apps locally before. First time using GatsbyJS.
awaiting author response question or discussion

Most helpful comment

@sidharthachatterjee thank you that worked. I went to Dev Tools > Application Tab > Service Worker > click 'Unregister Service Worker' and it now works.

Before that I also tried running it in a Chrome Incognito Window and Mozilla - both worked. Should have tried that sooner. But didn't know Service Worker could cause interference here.

All 5 comments

Its not finding some of the generated files in /public? Mismatch between what's being called and what exists?
screenshot from 2019-01-31 18-35-01

I ran into something similar when trying to build, and it was because an error was thrown in the build and there weren't generated HTML files in the public folder. You're saying public/index.html is there, but it's not loading for some reason?

Can't reproduce this locally

It seems like a lot of responses including the webpack runtime is coming from a service worker. Perhaps, a _previously_ run site on the same port registered a service worker?

Try clearing your application and service worker cache in Chrome and see if that fixes this?

@sidharthachatterjee thank you that worked. I went to Dev Tools > Application Tab > Service Worker > click 'Unregister Service Worker' and it now works.

Before that I also tried running it in a Chrome Incognito Window and Mozilla - both worked. Should have tried that sooner. But didn't know Service Worker could cause interference here.

Glad that worked, @thinkocapo

Thank you for using Gatsby!

Was this page helpful?
0 / 5 - 0 ratings