But nothing is already running on port 3000!!!!!
if "127.0.0.1 localhost" is not in your host.
when you run yarn start
. it tell you Something is already running on port 3000 ....
see detect-port#L58
the error msg should more friendly.
This is done purposefully because something running on the same port but different addresses is confusing at best.
I believe the message is already pretty friendly; it's saying something is running on port 3000
-- not that something is running on localhost:3000
.
Can you propose a better message?
This sounds like a bug to me.
If I run HOST=127.127.4.224 PORT=9080 yarn start
, the expected behavior is that the dev server binds to that host and port (like any other web server). It shouldn't matter whether any processes are bound to that port on a different address.
Running different processes on the same port but different addresses could be confusing, but I think it's a necessary feature (especially on multi-user systems). Maybe we could be very explicit in the startup message about which address and port are bound?
Hm, there's a lot of edge cases for this. I'd be open to a proposal better aligned to how this should work.
The problem is that when we bind to localhost, 0.0.0.0
, or ::
, we have to check many other addresses.
I'd even go as far as ::1
and 127.0.0.1
; maybe we can ignore checking the other hosts if it isn't one of these, what do you think?
I'm probably missing a lot of the complexity, but it seems like the behavior should be:
localhost
.3000
.I just had this problem and the quick fix is
Add
127.0.0.1 localhost
in your host.
It should be in the docs maybe?
@benhanks040888 adding
127.0.0.1 localhost
in the hosts
file
/etc/hosts for mac
C:\Windows\System32\Drivers\etchosts for windows
helped.
Thank you so much sir.
I think we'll be sticking to this default behavior for now -- it makes the most sense IMO.
Mainly because:
This is done purposefully because something running on the same port but different addresses is confusing at best.
this work for me
1 open chrome
2 open : localhost:3000
3 write something on your code
4 refesh tab on chrome -> it will crash
5 npm start again
6 done :)
To rephrase what piggy2303 said:
Just make an .env
file at root of your project and add this line,
PORT=3002
and type npm start
in cmd again.
Yep, https://github.com/facebookincubator/create-react-app/issues/2843#issuecomment-358685783 is the right solution if you often work on two apps side by side and want to customize the port for one of them.
Most helpful comment
this work for me
1 open chrome
2 open : localhost:3000
3 write something on your code
4 refesh tab on chrome -> it will crash
5 npm start again
6 done :)