9

Made a new react app using create-react-app and now getting the following error in the terminal when running npm start:

> react-scripts start

Attempting to bind to HOST environment variable: x86_64-apple-darwin13.4.0
If this was unintentional, check that you haven't mistakenly set it in your shell.


events.js:167
      throw er; // Unhandled 'error' event
  ^

Error: getaddrinfo ENOTFOUND x86_64-apple-darwin13.4.0
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
Emitted 'error' event at:
    at GetAddrInfoReqWrap.doListen [as callback] (net.js:1468:12)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! aqi@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the aqi@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely      additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/chris/.npm/_logs/2018-12-24T10_07_46_970Z-debug.log 

Tried removing the node-module folder and npm install.

9 Answers9

39

type unset HOST in the terminal. It will solve the issue.

Rafi Ud Daula Refat
  • 2,037
  • 16
  • 28
2

I struggled with this exact issue for an entire day. If you do unset HOST, it will solve it, but temporarily. The simple solution to this bug is as follows (this is for Mac, for Window the commands may differ):

  1. Open your bash with the following command: open ~/.bash_profile
  2. Write this down (exactly what it says) all the way down the file once the file opens: HOST="localhost"
  3. After that, save the file and quit (Command + q)
  4. Finally, reload the environment by typing this on the terminal: source ~/.bash_profile

If you do all the steps correctly, this should resolve the bug.

Aashish Chaubey
  • 538
  • 1
  • 5
  • 21
Zakir
  • 51
  • 3
1

I also struggled with this. Many online solutions only solve the first part. Here I'll provide my approach to fully solve the issue and make npm start work

Understand the issue:

There are 2 parts to the problem. First, you want to set your environmental variable, HOST, to "localhost". You can do it by typing in your terminal (anywhere):

  1. nano ~/.bash_profile
  2. In the bash file, type HOST="localhost" in a new line and type: export HOST. This directs your program to go to this HOST by default
  3. Save change by Ctrl + X, then press Y (Yes), then press Enter
  4. Return to your terminal, run: source ~/.bash_profile to refresh the terminal

Now, your computer has updated its HOST variable to localhost. You can check that by typing: env | grep HOST in the terminal. Grep means to grab that variable in the variable list.

Hopefully that solves the issue fully. If you then encounter: dyld: lazy symbol binding failed.

This simply means there's something wrong with the fsevents. Why? I am not sure, but a sure fix is by deleting the node_modules/fsevent files from my search. A permanent fix is to remove the node modules and re-do the npm install. Make sure that fsevent is version 2.0+!

Hope that helps. This surely took some time to debug!

References:

  1. dyld: lazy symbol binding failed: Symbol not found: _node_module_register
  2. https://medium.com/@choy/fixing-create-react-app-when-npm-fails-to-start-because-your-host-environment-variable-is-being-4c8a9fa0b461
  3. https://medium.com/@youngstone89/setting-up-environment-variables-in-mac-os-28e5941c771c
Ian Lee
  • 31
  • 2
0

Mostly the problem occurs when you set a specific hostname instead of regular used one localhost.

On Mac/Linux terminal run hostname, you will receive the specified hostname. If it's something different than localhost refer to your bash profile config file (ie for ZSH it's .zshrc, or for Bash it's .bashrc in your home directory); and if HOST=localhost exists in the profile comment it.

PS: do not forget to restart your terminal to make the change takes effect.

Esmaeil MIRZAEE
  • 786
  • 8
  • 12
0
unset HOST

This worked for me, if not, then run the code and give it a reboot

0

I ran into this issue because I usually had anaconda running as default in the terminal. So my login is not just my computer login account but appending with some string created by conda. (eg xxx@xxx)

However, in order to get the react server up and running normally you will need to have your login as your computer login id. (eg xxx@)

There are two solutions to achieve this.

  1. to run unset HOST, it will get rid of the string at @ of your terminal log in id.
  2. to add HOST as env var to your terminal config file. For zsh user (most likely cos mac now run zsh as default in the terminal) You need to add export HOST="localhost" or export HOST="" to ~/.zshrc and run source ~/.zshrc in the terminal to refresh the new zsh config. You can do the same to bash config file by following one of the answers above.

GOOD LUCK.

Methodist
  • 1
  • 1
0

Attempting to bind to HOST environment variable: x86_64-apple-darwin13.4.0 If this was unintentional, check that you haven't mistakenly set it in your shell.

This issue comes once we write npm start in terminal, to rectify the issue in your terminal before executing the command npm start write unset HOST then write the command npm start it works fine and you can check on localhost://3000

-1

I was able to fix the similar error by running npm install create-react-app instead of npm install -g create-react-app. Hope it helps.

monkrus
  • 740
  • 17
  • 20