Port 4200
is already in use.Use -port
to specify a different port error Reasons
An existing application(not angular) in your system using the port number 4200. This is a very rare scenario. In this case, you need to change the port number of angular application as mentioned below.
You already ran ng serve and to exit the application you typed Control Z (Ctrl+Z), And then you typed ng serve
then you will get port 4200 is already in use_ error. In this case, you need to kill the previous process.
To change the port number for our angular application use the below command
ng serve --port 4201
Now type ng serve
Our angular application will be running on http://localhost:4201
To fix port 4200 is already in use error in In Mac & Linux OS (Ubuntu etc) use the following commands
sudo kill $(sudo lsof -t -i:4200) Or
sudo kill `sudo lsof -t -i:4200` Or
sudo lsof -t -i tcp:4200 | xargs kill -9
In Window operating system open command prompt. Use the following command to fix port 4200 is already in use error.
netstat -a -n -o | findStr "4200"`
Take the process id and kill the process using the following command
taskkill -f /pid 11128
npx kill-port 4200