Mohammad Ajo
Mohammad Ajo

Reputation: 61

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

When trying to run ng serve I get the following error:

Port 4200 is already in use. Use '--port' to specify a different port.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `ng serve --host 0.0.0.0 --disable-host-check`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Mohammad Ajo\AppData\Roaming\npm-cache\_logs\2019-08-18T18_19_41_366Z-debug.log

I've checked the port if it's reserved by another connection or not and tried to change the port multiple times with not and keep getting the same error.

Upvotes: 3

Views: 14637

Answers (5)

hazan kazim
hazan kazim

Reputation: 958

For Linux users:- this one is working for me

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

Upvotes: 3

pamal Sahan
pamal Sahan

Reputation: 481

to connect asp.net web api project with angular I have given port 4200 to it.If you just not did like that you can use ng serve --port 4600 like another port it works for me.

Upvotes: 1

Sangwin Gawande
Sangwin Gawande

Reputation: 8166

Run following command, ---o will open new window automatically with different port :

ng serve ---o --port=0 // will open on random port automatically

If you want specific port then run :

ng serve ---o --port 4201 // Will open on port 4201

Upvotes: 0

iNano
iNano

Reputation: 58

I was facing the same issue just a couple of hours ago. Try checking out: https://github.com/angular/angular-cli/issues/15369

Installing [email protected] worked in my case.

Upvotes: 1

Dmitry Samoylov
Dmitry Samoylov

Reputation: 1318

Try running ng serve --port 4500 or change package.json and instead of

"start": "ng serve",

type

"start": "ng serve --port 4500",

and then run npm start command

Upvotes: 0

Related Questions