Reputation: 1234
I have two ember projects: project1, project 2
project1: ember s , port 4200 is working fine. I closed the project1 terminal and again tried to start ember s inside project2, when i do that, i am getting Port 4200 is already in use.
Port 4200 is already in use.
Why am i getting this error, as other instances where already killed and how to rectify it ?
Upvotes: 6
Views: 6854
Reputation: 3602
It's not really a solution, but I'm posting it anyway incase anyone suffers the same fate as me. All morning I've tried to boot an app on any port available, only to be met with No open port found above 0
.
After a tonne of trial and error, what fixed it was rebooting the Mac. Even though it had only just done a fresh boot ¯\(ツ)/¯
UPDATE: it seems as though specifying a port and host in .ember-cli
was affecting this. Oddly, if you specify the same values as command line arguments it works fine ¯_(ツ)_/¯
Upvotes: 1
Reputation: 4046
The following solution works on Mac & Linux.
Try using:
ember serve --port 0
Per ember help: "Pass 0 to automatically pick an available port". (In a terminal, type ember help
).
This approach can also work to run more than one ember site at the same time. It helps you find an available port as well as a different live-reload-port for each:
ember serve --port 0 --live-reload-port 0
If you get the same error in any of these cases, you can also enter the following python script at your Terminal prompt to identify an available port:
python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()'
You can then specify ports you know to be available:
ember serve --port <known_port_1> --live-reload-port <known_port_2>
Upvotes: 3
Reputation: 491
None of the answers work on Mac so I'm posting this solution.
kill -9 $(lsof -i tcp:4200 -t)
Upvotes: 11
Reputation: 12872
I extended my comment as answer for windows user,
To see the 4200 is already in use or not, if so what process is holding port, run the below command
netstat -ano | findstr :4200
This will show some result like this,
TCP 0.0.0.0:4200 0.0.0.0:0 LISTENING 12784
TCP [::]:4200 [::]:0 LISTENING 12784
which will list out list of processes using 4200 port. you can find process id in the result. in the above result pid is 12784 . We need to kill this process to free port.
TaskKill.exe /F /PID 12784
Upvotes: 4
Reputation: 997
Try the following,
sudo fuser -k 4200/tcp
It will kill all process belongs to port 4200.
Upvotes: 11