Port 4200 is already in use.Use ‘-port’ to specify a different port error Reasons

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 close or terminate the angular instance always use Control+C (Ctrl+c)

And ng serve uses default port number 4200 to run the angular application. And our application URL will be http://localhost:4200. To avoid this error we need to change the port number to other port which is free.

According to RFC 793 port numbers is a 16-bit unassigned integer. The minimum value is 0 and the maximum value is 65535.

And, within this range, ports 0 – 1023 are reserved for specific purposes(mostly).

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 kill already existing angular process use the below commands

Fix Port 4200 is already in use.Use ‘-port’ to specify a different port error in Mac & Linux
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
Fix Port 4200 is already in use.Use ‘-port’ to specify a different port error in Window
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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值