I am learning angular 2 and for the first time I am using the angular CLI project to create a sandbox project.
I was able to run the command \"ng serve\" and it wor
ng serve --port 4201 --live-reload-port 4200
and access using localhost:4201
This should work as a temporary solution.
or
try listing port usage using
lsof -i:4200
and kill it manually using
sudo kill -9 <Process PID using port 4200>
netstat -anp | grep ":4200"
This will tell you who's got the port.
Open your cmd.exe
as administrator
,
then Find the PID
of port 4200
netstat -ano | findstr :4200
Here i have 3 PID :
LISTENING
kill only port 4200 (kill the red PID):
taskkill /PID 15940 /F
note : kill the green one will only lead your browser closed by force.
now you can do "ng-serve" to start your angular app at the same port 4200
Additional Stuff :
One liner : After looking a way to optimize this, Here is the One-liner command of this answer : (special thanks to : Josep Alsina for this tips)
for /f "tokens=5" %a in ('netstat -ano ^| find "4200" ^| find "LISTENING"') do taskkill /f /pid %a
On Mac OS X you need the following command:
sudo lsof -t -i tcp:4200 | xargs kill -9
Remember you need to kill Angular's web server with Command+C.
I was facing the same issue every time I have to kill the port.
I tried ./node_modules/.bin/ng serve --proxy-config proxy.conf.json --host 0.0.0.0
Instead of npm start
and its works
Kill process and close the terminal which you used for running the app on that port.