Fix "Unable to Find Package" NuGet Error in Visual Studio C#
When I tried to run the "ng-serve" command again it gives me "Port 4200 is already in use."
What is Port Number and how problems arise?
Actually the port number is used to find particular applications in a network. Sometimes two application tries to use the same port. Suppose Application A is using port XXXX then when another application says Application B tries to use the same port number then the above problem may arise. Here I am using port XXXX as Port 4200.
Solution:
Method 1:
So, in this method, we have to kill the process running on this port and again reuse that port.So lets start
Step1: Open cmd and type as below
Here we can see Port 4200 is used by Process ID: 12868 as we have status as LISTENING so we must kill a process running on this PID
Step2: Forcefully Killing Process ID 12868 as shown below
Step 3: Now you can do "ng-serve" to start your angular app at the same port 4200
Method 2:
Try using another port to serve the current angular project.
ng serve --port 12012
Here I have specified port number 12012. But this is not best practice because here each time i am doing ng serve I have to use different cases. So this is just an alternative solution but doesn't use it.
First, open a terminal and kill the process 4200 as shown below:
sudo kill `sudo lsof -t -i:4200`
This will kill all processes running at post number 4200 and your angular project will run now.