Create-react-app: localhost:3000 refused to connect

Created on 24 Jul 2017  路  16Comments  路  Source: facebook/create-react-app

But I run in http://192.168.43.52:3000 then it's fine, strange, I used to be running on localhost:3000, what's the issue here?

low (ignored issue template)

Most helpful comment

I know this is closed already, but in case someone finds this, here is the solution that worked for me. I'm on a Mac and it is connected to the wifi with DHCP. The name of the mac is not recognized by the DNS, so when I run "yarn start", the browser cannot go to "http://mymacsname:3000". Even switching to "localhost:3000" or "127.0.0.1:3000" didn't work.

The solution was to unset the HOST environment variable on the command-line before you issue "yarn start" so that it would use "localhost" to start the server instead of the mac's name. THEN, when I went to the browser and typed in "localhost:3000" it worked just fine and I could see my react app.

All 16 comments

We鈥檒l need more details: OS, react-scripts version, Node version, what messages you see and where, screenshots etc. The issue doesn鈥檛 contain enough information to let us help you.

react-scripts version: "1.0.10"
OS: "Mac OSX EL Capitan version 10.11.3"
node version: v6.9.0
npm version: v4.4.1

screen shot 2017-07-24 at 10 32 57 pm

Any change you have proxies, or something unusual in /etc/hosts?

Nope, I can run other app which also run at port 3000. I even tried to restart my laptop, no luck.

Is the environment var HOST defined? Try running echo $HOST.

@Timer I don't see any output doing echo $HOST

Hmm, that's odd -- I'm not sure what'd be causing this other than what @gaearon suggested. Seems silly but I assume a reboot didn't fix the problem? Was it always like this?

Maybe try running killall -9 node?

I tried to reboot, didn't solve the issue. Will try to create a new project and try again, it used to work.

Tried my PC, worked on windows, strange.

@eldyvoon can you post a screenshot of your terminal?

I'll close this because we can't help you, I'm really sorry. I hope you've figured it out.

I had a similar problem this morning and couldn't find a solution online. I tried to delete the package.lock.json and yarn.lock and the problem did not recur. Any explanation possibly?

I know this is closed already, but in case someone finds this, here is the solution that worked for me. I'm on a Mac and it is connected to the wifi with DHCP. The name of the mac is not recognized by the DNS, so when I run "yarn start", the browser cannot go to "http://mymacsname:3000". Even switching to "localhost:3000" or "127.0.0.1:3000" didn't work.

The solution was to unset the HOST environment variable on the command-line before you issue "yarn start" so that it would use "localhost" to start the server instead of the mac's name. THEN, when I went to the browser and typed in "localhost:3000" it worked just fine and I could see my react app.

@ehoogerbeets what do you mean by unset the HOST environment variable? I'm having the same issue right now, and it's weird/frustrating because it was working fine about an hour ago.

If you are using bash or a bash-like command-line shell, you can unset the environment variable with

export HOST=

If you have a tcsh or csh like command-line shell, you can unset it with:

unsetenv HOST

Do these before you run yarn start and things may go smoother for you if you had the same problem that I did.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rdamian3 picture rdamian3  路  3Comments

AlexeyRyashencev picture AlexeyRyashencev  路  3Comments

onelson picture onelson  路  3Comments

Aranir picture Aranir  路  3Comments

fson picture fson  路  3Comments