Gatsby: error UNHANDLED EXCEPTION Error: getaddrinfo ENOTFOUND localhost

Created on 9 Feb 2019  ยท  7Comments  ยท  Source: gatsbyjs/gatsby

Description

If I run gastby develop I get this error message.

error UNHANDLED EXCEPTION


  Error: getaddrinfo ENOTFOUND localhost

I found If I restart my machine the issue will disappear. After 30 minutes of work, the issues reappear.

Steps to reproduce

type gatsby develop
Console Returns

success open and validate gatsby-configs โ€” 0.007 s
success load plugins โ€” 0.187 s
success onPreInit โ€” 0.207 s
success delete html and css files from previous builds โ€” 0.010 s
success initialize cache โ€” 0.005 s
success copy gatsby files โ€” 0.064 s
success onPreBootstrap โ€” 0.004 s
success source and transform nodes โ€” 0.045 s
success building schema โ€” 0.200 s
success createPages โ€” 0.001 s
success createPagesStatefully โ€” 0.034 s
success onPreExtractQueries โ€” 0.004 s
success update schema โ€” 0.116 s
success extract queries from components โ€” 0.124 s
success run graphql queries โ€” 0.033 s โ€” 6/6 185.27 queries/second
success write out page data โ€” 0.005 s
success write out redirect data โ€” 0.001 s
โ „ onPostBootstrapdone generating icons for manifest
success onPostBootstrap โ€” 0.131 s

info bootstrap finished - 2.876 s

Environment

  System:
    OS: macOS 10.14.1
    CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
    Shell: 5.5.1 - /usr/local/bin/zsh
  Binaries:
    Node: 10.10.0 - /usr/local/bin/node
    Yarn: 1.9.4 - /usr/local/bin/yarn
    npm: 6.4.1 - /usr/local/bin/npm
  Languages:
    Python: 2.7.10 - /usr/bin/python
  Browsers:
    Chrome: 72.0.3626.96
    Firefox: 65.0
    Safari: 12.0.1
  npmPackages:
    gatsby: ^2.0.114 => 2.0.114 
    gatsby-image: ^2.0.29 => 2.0.29 
    gatsby-plugin-google-analytics: ^2.0.13 => 2.0.13 
    gatsby-plugin-manifest: ^2.0.17 => 2.0.17 
    gatsby-plugin-offline: ^2.0.22 => 2.0.22 
    gatsby-plugin-react-helmet: ^3.0.6 => 3.0.6 
    gatsby-plugin-sass: ^2.0.10 => 2.0.10 
    gatsby-plugin-sharp: ^2.0.20 => 2.0.20 
    gatsby-plugin-sitemap: ^2.0.5 => 2.0.5 
    gatsby-source-filesystem: ^2.0.20 => 2.0.20 
    gatsby-transformer-sharp: ^2.1.13 => 2.1.13 
  npmGlobalPackages:
    gatsby-cli: 2.4.9

Most helpful comment

@pcabrera83 see here for the hosts.
By default the hosts file should look something like this:

##
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost

All 7 comments

@pcabrera83 that particular issue you're experiencing might be the result of two things,

  • A corrupt hosts file
  • Another app running on the same port and even when it's closed it's not released.

Check if there's anything wrong with the said file, to see if it solves it.
Feel free to provide feedback so that we can close this issue or come up with a solution for your issue.

Where do I find the hosts file or check if another app is running on the same port?

On Sat, Feb 9, 2019, 1:06 PM jonniebigodes <[email protected] wrote:

@pcabrera83 https://github.com/pcabrera83 that particular issue you're
experiencing might be the result of two things,

  • A corrupt hosts file
  • Another app running on the same port and even when it's closed it's
    not released.

Check if there's anything wrong with the said file, to see if it solves it.
Feel free to provide feedback so that we can close this issue or come up
with a solution for your issue.

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/gatsbyjs/gatsby/issues/11666#issuecomment-462065968,
or mute the thread
https://github.com/notifications/unsubscribe-auth/APktAxWCtz-siqXgLm_z5O0AwCiK_ZVzks5vLw4lgaJpZM4ayp8x
.

@pcabrera83 see here for the hosts.
By default the hosts file should look something like this:

##
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost

I found it but my file is empty. Should I copy and paste what you have?

Yep, that worked. I copied and pasted what you have and it seems to be working now.
Here is an article that covers this.

@pcabrera83 test it a little bit more and if the issue does not happen, feel free to close this issue and should any more arise, open a new one. Sounds good?

thanks @jonniebigodes for helping out! ๐Ÿ’ช

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KyleAMathews picture KyleAMathews  ยท  3Comments

timbrandin picture timbrandin  ยท  3Comments

andykais picture andykais  ยท  3Comments

theduke picture theduke  ยท  3Comments

signalwerk picture signalwerk  ยท  3Comments