• Register
0 votes

Problem :

Currently I am trying to learning angular 2 and angular CLI also I am using the angular CLI and angular 2 for a very first time to create the sandbox project.

I ran the following command "ng serve" and it worked for me. After that I wanted to stop the command so I pressed the "Control Z".

But now if I try to run the "ng-serve" command again then it gives me below error:

"Port 4200 is already in use. use '--port' to specify a different port."

I am trying to fix this error from past couple of days but unable to fix it. Can somebody help me in fixing it ?
8 4 2
2,300 points

2 Answers

0 votes

Solution :

I had also faced the error related to port 4200 recently. I followed below ways to kill the progress on the port number 4200

If you are using Linux :

Then use the below command to fix it

sudo kill $(sudo lsof -t -i:4200)

You could also try below command:

sudo kill `sudo lsof -t -i:4200`

If you are using Windows :

Then you need to open your cmd as administrator and type below command in your cmd:

netstat -a -n -o

After that you need to find the port with port number 4200 by just right clicking on your terminal and then click on find, enter the 4200 in your "find what" and then click on the "find next": If you found that the port number 4200 is used by the pid 18932. Then you need to type below command in cmd:

taskkill -f /pid 18932
5 2 1
4,980 points
0 votes


This is what I used to kill the progress on port 4200

For linux users:

sudo kill $(sudo lsof -t -i:4200)

You could also try this:

sudo kill `sudo lsof -t -i:4200`

For windows users:

Port number 4200 is already in use. Open the cmd as administrator. Type below command in cmd:

netstat -a -n -o

And then, find port with port number 4200 by right click on terminal and click find, enter 4200 in "find what" and click "find next": Let say you found that port number 4200 is used by pid 18932. Type below command in cmd:

taskkill -f /pid 18932


alias ngf='kill -9  $(lsof -t -i:4200);ng serve'

Now run ngf (instead of ng serve) in terminal from the project folder. This will kill all processes using the port 4200 and runs your Angular project.

Step 1: Find the connection’s PID

> netstat -ano | findstr :yourPortNumber

Step 2: Kill the process using it’s PID

> tskill yourPID

Step 3: Restart your server

You should be able to run it (using ng serve)

Step 4: Stop your server properly

Don’t forget now to close properly your server by using Ctrl + C and typing Y:
10 6 4
31,120 points

Related questions

0 votes
1 answer 1.5K views
Problem : I am facing following error when I try to use the CLI to create a new component : Could not find an ngmodule. use the skip-import option to skip importing in ngmodule. using below command : ng g c my-component --project=my-project But no component is created. I also tried by dropping the --project ... :- 6.0.6 5. Rxjs:- 6.2.1 6. Typescript:- 2.7.2 7. Webpack :- 4.8.3 8. nrwl/nx:- 6.1.0
asked Dec 9, 2019 alecxe 7.5k points
0 votes
1 answer 18 views
Problem: I am getting following message when i run angualr2 program with typescript. angular is running in the development mode. call enableprodmode() to enable the production mode. What is the reason for this message is it a deployment option? Curious for feedback ?
asked Jul 16 quizzBabes 160 points
0 votes
2 answers 533 views
Problem : I want to upload the finished android app to a android market but I am getting below error: “You need to use a different package name because "com.example" is restricted.”
asked Jan 22 jwilliam 3.9k points
0 votes
1 answer 2K views
Problem : I am facing following error from the Angular 2 core.umd.js:5995 EXCEPTION: Uncaught (in promise): Error: Error in app/model_exposure_currencies/model_exposure_currencies.component.html:57:18 caused by: If ngModel is used within a form tag, either the name attribute must be set or the form ... 0-9]+)?" required> </div> </td> Below is my form tag: <form #f="ngForm" (ngSubmit)="onSubmit()">
asked Dec 3, 2019 alecxe 7.5k points
1 vote
1 answer 34 views
Problem: I have gained fundamental knowledge on Angular2. I am taking help of online tutorials to learn Angular2. I am trying to create the angular 2 App with the angular cli I have written below command in my cmd: npm install angular-cli -g After above command I am ... an error . I am unable to debug above error. I need Angular2 expert who can help me in fixing above Angular2 error for me.
asked Jun 5 Martin K 6.6k points