question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ng serve --open reports port 4200 is already in use when it isn't

See original GitHub issue

ng serve --open incorrectly reports that port 4200 is in use, even when no browsers are open.

Versions

Angular CLI: 1.6.7
Node: 8.9.4
OS: win32 x64
Angular: 5.2.3
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.6.7
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/core: 0.0.29
@angular-devkit/schematics: 0.0.52
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.7
@schematics/angular: 0.1.17
typescript: 2.5.3
webpack: 3.10.0

Repro steps

  • ng new aatest1 -si
  • cd aatest1
  • npm install
  • ng serve --open

Observed behavior

ps>ng serve --open
Port 4200 is already in use. Use '--port' to specify a different port.

Desired behavior

ng serve --open should work correctly

Mention any other details that might be useful (optional)

The above behavior did NOT occur with Angular-CLI 1.6.6 or earlier.

Work-around

specify --port 4216 (any value between 4200 and 4215 causes the above mentioned error)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:18 (1 by maintainers)

github_iconTop GitHub Comments

16reactions
singhkeshavcommented, Jul 27, 2018

fuser -n tcp -k 4200 ng serve

12reactions
fmorrisocommented, Feb 6, 2018
ps>sl aaTest1
ps>ng serve --open
Port 4200 is already in use. Use '--port' to specify a different port.
ps>netstat -abno | out-file "$env:temp\aatest.txt" -Force -Width 1024 -encoding ASCII
ps>npp "$env:temp\aatest.txt"
ps>

I have attached the output from netstat. I cannot find anything that is listening on ports 4200 through 4215, the ones that no longer work as of Angular-CLI 1.6.7.

It’s as if the parsing of the default port number’s last two digits (00) is messed up because specifying port 4216 or above seems to work.

If I specify port 4201, for example, I still get the same error (port 4201 is in use):

ng serve --open --port=4201

Only ports 4216 and above work for me. Example:

ng serve --open --port=4216

aatest.txt

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Port 4200 is already in use" when running the ng serve ...
In this case, you need to change the port number of angular application as mentioned below. You already ran ng serve and to...
Read more >
Port 4200 Is Already In Use. Use '–Port' To Specify A Different ...
Port 4200 is already in use. Use --port to specify a different port error occures sometimes when we run our angular app using...
Read more >
“Port 4200 is Already in Use” When Running the ng serve ...
As we know, the ng serve uses default port number 4200 to run the angular application. And our application URL will be http://localhost:4200....
Read more >
Why is Angular's port 4200? - Quora
It's not really Angular's port — it's the default port chosen by Angular CLI. The number 4200 serves no particular purpose other than...
Read more >
Angular Server Port 4200 is already in use ng serve command
In this video I will show you, "How to fix Angular Server Port 4200 is already in use "Commands:netstat -a -o -ntaskkill -F...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found