• Register
0 votes
60 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 14 views
14 views
I was working on that but I got into some problems.
asked Dec 1, 2020 TeamScript 9.2k points
0 votes
1 answer 1.8K views
1.8K 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 68 views
68 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, 2020 quizzBabes 160 points
0 votes
2 answers 822 views
822 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, 2020 jwilliam 3.9k points
0 votes
1 answer 2.6K views
2.6K 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 40 views
40 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, 2020 Martin K 6.6k points
1 vote
1 answer 139 views
139 views
Problem : I am getting following kubernetes error and dont understand why command line is trying to connect to localhost? the connection to the server localhost:8080 was refused - did you specify the right host or port?
asked Nov 11, 2019 peterlaw 6.9k points
0 votes
1 answer 2.3K views
2.3K views
Problem: I am beginner to Angular. I have recently started working in Angular project but I am facing below bizarre error: &ldquo;Can't bind to 'ngIf' since it isn't a known property of 'div'.&rdquo; The element is I guess <div [ngIf]="isAuth" id="sidebar ... is the child component. In my parent component i.e. App component the ngif works properly. Please Note: I am currently using Angular RC5.
asked Aug 17, 2020 Raphael Pacheco 4.9k points
1 vote
1 answer 174 views
174 views
Problem : I am very new to Angular2. Currently I am trying to create the component after that it is set to the root component but still I am facing below error: Template parse errors: Can't bind to 'routerLink' since it isn't a known property of 'a'. I ... days on researching and trying to fix above error but unable to fix it so now I need Angular2 experts advice to quick fix my Angular2 error.
asked May 2, 2020 stewart 4k points
1 vote
2 answers 130 views
130 views
Problem : I am beginner to Angular2. Currently I am trying to create a simple form in the Angular2 app but it is not working for me. I am facing below error. &ldquo;Can't bind to 'formGroup' since it isn't a known property of 'form'.&rdquo; I am struggling on this error from couple of days. Still I don&rsquo;t know how to fix above error. Is it possible for somebody to fix it for me?
asked Mar 27, 2020 morrisBson 3.2k points