• Register
0 votes
99 views

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

Please log in or register to answer this question.

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

Solution:

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

For UNIX:

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 3 views
3 views
Problem I want to use angular material in angular 6,help me to do it.
asked 3 days ago salim1 30.9k points
0 votes
1 answer 6 views
6 views
Problem: I am facing the following problem : Could not find an ngmodule. use the skip-import option to skip importing in ngmodule .
asked Mar 13 Wafa Abu Yousef 6.1k points
0 votes
1 answer 27 views
27 views
I was working on that but I got into some problems.
asked Dec 1, 2020 TeamScript 13.5k points
0 votes
1 answer 2.2K views
2.2K 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 16 views
16 views
Problem: I have the following error when starting my angular application, even if the component is not showing. I have to comment on the way my app works. zone.js:461 Unhandled Promise rejection: Template parse errors: Can't bind to 'ngModel' since it ... /details/intervention.details.css'] }) export class InterventionDetails { @Input() intervention: Intervention; public test : string = "toto"; }
asked Feb 26 sasha 16.2k points
0 votes
1 answer 1 view
1 view
Problem: I have a problem with HTTP in Angular. “This.http.get(...).map is not a function” Someone assist me how to do it.
asked 2 hours ago muktaa 1.3k points
0 votes
1 answer 3 views
3 views
Problem: As I mentioned in my previous query, I'm having difficulties with my learning; I've tried searching the web but haven't been able to find adequate information; could you assist me in continuing my project?
asked Apr 1 rakib1 51.3k points
0 votes
1 answer 13 views
13 views
Problem: I have tried all of the solutions suggested and still not be able to fix 'mat-toolbar' problem. Please help me with some advice.
asked Mar 31 zayed1 24.7k points
0 votes
1 answer 2 views
2 views
Problem: created my routing in my app. module. But when I run this I get the following error: Router-outlet' is not a known element: It gives an error telling me that Visual Studio cannot resolve the tag 'router outlet. Any suggestions on how I can fix this error?
asked Mar 27 ummesalma 22k points
0 votes
1 answer 16 views
16 views
Problem: I was able to install Angular. Anytime I tried to run ng, I would get: the term 'ng' is not recognized as the name of a cmdlet
asked Mar 20 ummesalma 22k points