create-react-app: After create-react-app, `npm start` not work

Describe the bug

I follow the process on (https://reactjs.org/docs/create-a-new-react-app.html) to Create React App, npx create-react-app my-app cd my-app npm start But npm start can not work and the essor message as below,

> my-app@0.1.0 start /Users/cortey/Documents/GitHub/WebProject-React/my-app
> 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.
Learn more here: https://bit.ly/CRA-advanced-config

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

Error: getaddrinfo ENOTFOUND x86_64-apple-darwin13.4.0
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
Emitted 'error' event at:
    at GetAddrInfoReqWrap.doListen [as callback] (net.js:1457:12)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the my-app@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/cortey/.npm/_logs/2020-07-17T04_51_32_683Z-debug.log

The complete log of this run is here,

0 info it worked if it ends with ok
1 verbose cli [ '/Users/cortey/.nvm/versions/node/v10.16.0/bin/node',
1 verbose cli   '/Users/cortey/.nvm/versions/node/v10.16.0/bin/npm',
1 verbose cli   'start' ]
2 info using npm@6.14.6
3 info using node@v10.16.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle my-app@0.1.0~prestart: my-app@0.1.0
6 info lifecycle my-app@0.1.0~start: my-app@0.1.0
7 verbose lifecycle my-app@0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle my-app@0.1.0~start: PATH: /Users/cortey/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/cortey/Documents/GitHub/WebProject-React/my-app/node_modules/.bin:/Users/cortey/.nvm/versions/node/v10.16.0/bin:/anaconda3/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/mysql/bin:/usr/local/mysql/support-files:/Applications/Postgres.app/Contents/Versions/11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/cortey/.nvm/versions/node/v10.16.0/bin:/Users/cortey/opt/anaconda3/bin:/Users/cortey/opt/anaconda3/condabin:/anaconda3/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin
9 verbose lifecycle my-app@0.1.0~start: CWD: /Users/cortey/Documents/GitHub/WebProject-React/my-app
10 silly lifecycle my-app@0.1.0~start: Args: [ '-c', 'react-scripts start' ]
11 silly lifecycle my-app@0.1.0~start: Returned: code: 1  signal: null
12 info lifecycle my-app@0.1.0~start: Failed to exec start script
13 verbose stack Error: my-app@0.1.0 start: `react-scripts start`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/Users/cortey/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:198:13)
13 verbose stack     at ChildProcess.<anonymous> (/Users/cortey/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:198:13)
13 verbose stack     at maybeClose (internal/child_process.js:982:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid my-app@0.1.0
15 verbose cwd /Users/cortey/Documents/GitHub/WebProject-React/my-app
16 verbose Darwin 19.3.0
17 verbose argv "/Users/cortey/.nvm/versions/node/v10.16.0/bin/node" "/Users/cortey/.nvm/versions/node/v10.16.0/bin/npm" "start"
18 verbose node v10.16.0
19 verbose npm  v6.14.6
20 error code ELIFECYCLE
21 error errno 1
22 error my-app@0.1.0 start: `react-scripts start`
22 error Exit status 1
23 error Failed at the my-app@0.1.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Actually, I npx create-react-app my-app one month ago, and it works! But today, I can create a new one but cannot run it. Plus, I changed my hosts yesterday, just add a domain, so it seems not the hosts problem.

My etc/hosts file

##
# 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
127.0.0.1 api.promernstack.com ui.promernstack.com

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 23 (1 by maintainers)

Most upvoted comments

This problem is only present with react-scripts@3.0.0, downgrading to react-scripts@2.1.8 resolved the issue. TRY THIS

create-react-app my-app
cd my-app
npm install react-scripts@2.1.8
npm start

No need to downgrade react-script

Add .env file inside project folder (outside src folder) and add a line mentioned below:- SKIP_PREFLIGHT_CHECK=true then npm start

This problem is only present with react-scripts@3.0.0, downgrading to react-scripts@2.1.8 resolved the issue. TRY THIS

create-react-app my-app
cd my-app
npm install react-scripts@2.1.8
npm start

Simple solution is unset the host using this command in terminal. unset HOST

But, this is temporary one and need to be fixed in future. Try the solution mention below to fix the bug. Steps:

  1. Open the bash: open ~/.bash_profile
  2. Write this down (exactly what it says) all the way down the file once the file opens: HOST="localhost"
  3. Save the file and quit Command + q
  4. Finally, reload the environment: source ~/.bash_profile

It works! Thanks, @aathil-Mr-ITGuy ! So do you think it is the issue related to etc/hosts files? I am still confused about the logic of this issue, could you please give me some reference to figure out why it happened?

Add .env file inside project folder (outside src folder) and add a line mentioned below:- SKIP_PREFLIGHT_CHECK=true

then npm install npm start

@tuoying96 I am glad @aathil-Mr-ITGuy’s suggestion works, I would recommend checking out Windows Environment variables on your machine and seeing if HOST is set there.

unset HOST will only persist for that shell session.

You may have some sort of virtual machine or something that has set this as a system variable for whatever reason.

Can you please tell how to start the first step? I am searching this file through search but can’t find it.

Hi @shubhamkrswarnkar, Do you mean the step of @aathil-Mr-ITGuy answer: open ~/.bash_profile? If yes, I think you can just type open ~/.bash_profile in your current terminal, and the .bash_profile will display. By the way, I used the temporary solution unset HOST, because I want to figure out what caused this issue at first.