Error: Port XXXX is already in use. Use --port to specify a different port.When I tried to run the ng-serve command

👤 Diwas Poudel    🕒 Mar 16 2019    📁 FIX

 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.


For Windows User

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

check which port is used

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

killing process

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.


For Linux User

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.



Ourtechroom Main Logo
Hello and thank you for visiting! We'll talk about everything from how to troubleshoot tech issues, to emerging technology, games, gadgets, and fun facts about technology.
Contact :