Create-react-app: Inform user they've specified a HOST

Created on 9 Jan 2018  路  12Comments  路  Source: facebook/create-react-app

OS

macOS 10.13.2

Node

node -v: 9.3.0
npm -v: 5.6.0
yarn -v: 1.3.2

output:

$ yarn start                                                                                                                                                                                       06:51:09
yarn run v1.3.2
warning ../../../package.json: No license field
$ react-scripts start
Could not find an open port at Giorgios-MacBook-Pro.
Network error message: listen EADDRNOTAVAIL 54.72.52.58

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

rebooted many times, updated node and npm, updated yarn and create-react-app,
but this only seems to works with sudo.

i also tried to reinstall node with nvm, after stumbling against many reports that suggested this was the cause of my issue.

this is probably a stupid bug, but it's driving me crazy since yesterday,
please help.

claimed enhancement

Most helpful comment

You've most likely set your HOST in your .bash_profile erroneously.

Please remove this entry or unset HOST before running npm start.

sudo scutil --set HostName change-hostname-like-this

All 12 comments

Seems something network-related. Can you try on another network?

tried with an hotspot and reset the home router.

the error persists.

but shouldn't this work even if my machine is not connected to the internet?
the address should be pointing at 127.0.0.1 after all.

could be that something else is using the 3000 port?
if you run lsof -n -i:3000 | grep LISTEN should be empty

lsof -n -i:3000 | grep LISTEN returns empty

running the command after disabling the network connections returns this error:

$ yarn start 
yarn run v1.3.2
warning ../../../package.json: No license field
$ react-scripts start
Could not find an open port at Giorgios-MacBook-Pro.
Network error message: getaddrinfo ENOTFOUND Giorgios-MacBook-Pro

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

which looks pretty weird to me since the development server should start on localhost

You've most likely set your HOST in your .bash_profile erroneously.

Please remove this entry or unset HOST before running npm start.

sudo scutil --set HostName change-hostname-like-this

hmm funny thing, there is no .bash_profile, nor .bashrc on my machine

Im using fish shell

added set -x HOSTNAME (hostname -s) to my config.fish
now echo $HOST returns empty
and echo $HOSTNAME returns a string

everything is fine, the web server is working, i can sleep now.

thank you guys.

Nice! Thanks @timer for debugging this.

Is there any warning we could add to make this easier?

I think that'd be nice. We can add a message along the lines:

Attempting to bind to $HOST because it was specified.
If this was unintentional, check that you haven't mistakenly set it in your shell.
<link to docs>

This message would be cleared right after a successful bind, so it'd only be visible when you hit this error state.

If you're looking for someone to implement this feature I'd be happy to help.

Feel free!

Turns out this was literally just a matter of checking for the environment variable and showing the warning message. No other changes required. 馃榾

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stopachka picture stopachka  路  3Comments

adrice727 picture adrice727  路  3Comments

alleroux picture alleroux  路  3Comments

fson picture fson  路  3Comments

ap13p picture ap13p  路  3Comments