gatsby: FetchError: request to http://localhost:8000/___graphql failed, reason: socket hang up

This might be related to https://github.com/gatsbyjs/gatsby/issues/14990 and https://github.com/gatsbyjs/gatsby/issues/15441.

Description

After environment set up, I created new Gatsby project with Hello World starter. I changed into the directory and ran gatsby develop.

The process completed to show me the localhost URL but immediately returned an error and quit the process.

I previously tried deleting node_modules and reinstalling packages with npm i but same thing happens.

Steps to reproduce

  1. gatsby new hello-world https://github.com/gatsbyjs/gatsby-starter-hello-world
  2. cd hello-world
  3. gatsby develop

Expected result

Web server should run to allow localhost:8000 to run in browser

Actual result

I’ll paste the last lines including localhost.

You can now view gatsby-starter-hello-world in the browser.
⠀
  http://localhost:8000/
⠀
View GraphiQL, an in-browser IDE, to explore your site's data and schema
⠀
  http://localhost:8000/___graphql
⠀
Note that the development build is not optimized.
To create a production build, use npm run build
⠀
⚠ 「wdm」:
ℹ 「wdm」: Compiled with warnings.


————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————0 pages                                                                                                                                                                           gatsby-starter-hello-world
 ERROR 

UNHANDLED REJECTION request to http://localhost:8000/___graphql failed, reason: socket hang up



  FetchError: request to http://localhost:8000/___graphql failed, reason: socket hang up

  - index.js:1455 ClientRequest.<anonymous>
    [gatsby]/[gatsby-cli]/[node-fetch]/lib/index.js:1455:11

  - next_tick.js:63 process._tickCallback
    internal/process/next_tick.js:63:19

Environment

Windows 10 1903 Build 18362.295

  System:
    OS: Linux 4.4 Ubuntu 18.04.3 LTS (Bionic Beaver)
    CPU: (8) x64 Intel(R) Core(TM) i7-8705G CPU @ 3.10GHz
    Shell: 4.4.20 - /bin/bash
  Binaries:
    Node: 10.16.3 - ~/.nvm/versions/node/v10.16.3/bin/node
    Yarn: 1.17.3 - ~/.nvm/versions/node/v10.16.3/bin/yarn
    npm: 6.10.3 - ~/.nvm/versions/node/v10.16.3/bin/npm
  Languages:
    Python: 2.7.15+ - /usr/bin/python
  npmGlobalPackages:
    gatsby-cli: 2.7.31

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

We worked around this issue by switching ports! Used gatsby develop -p 8002

I have the exact same issue, and I’m using WSL. Sometimes (rarely) it happens in the same way as @asuh reported, right after compilation is complete. Most of the time however it happens some time (from a few minutes, to a few hours) after starting the development server. I’ve tried disabling the firewall, but it still persists.

I’m running the same build as both you.

 System:
    OS: Linux 4.4 Ubuntu 18.04.1 LTS (Bionic Beaver)
    CPU: (8) x64 Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
    Shell: 4.4.19 - /bin/bash
  Binaries:
    Node: 10.16.2 - /usr/local/bin/node
    npm: 6.10.3 - /usr/local/bin/npm
  Languages:
    Python: 2.7.15+ - /usr/bin/python
  npmPackages:
    gatsby: ^2.13.67 => 2.13.67
    gatsby-image: ^2.2.8 => 2.2.8
    gatsby-plugin-alias-imports: ^1.0.5 => 1.0.5
    gatsby-plugin-create-client-paths: ^2.1.3 => 2.1.3
    gatsby-plugin-eslint: ^2.0.5 => 2.0.5
    gatsby-plugin-layout: ^1.1.3 => 1.1.3
    gatsby-plugin-preconnect: ^1.0.5 => 1.0.5
    gatsby-plugin-prefetch-google-fonts: ^1.4.3 => 1.4.3
    gatsby-plugin-purgecss: ^4.0.0 => 4.0.0
    gatsby-plugin-react-helmet: ^3.1.3 => 3.1.3
    gatsby-plugin-react-svg: ^2.1.2 => 2.1.2
    gatsby-plugin-robots-txt: ^1.5.0 => 1.5.0
    gatsby-plugin-sass: ^2.1.8 => 2.1.8
    gatsby-plugin-segment-js: ^3.0.1 => 3.0.1
    gatsby-plugin-sharp: ^2.2.12 => 2.2.12
    gatsby-plugin-sitemap: ^2.2.6 => 2.2.6
    gatsby-plugin-webpack-bundle-analyzer: ^1.0.5 => 1.0.5
    gatsby-source-filesystem: ^2.1.9 => 2.1.9
    gatsby-transformer-sharp: ^2.2.6 => 2.2.6