port 4200 is already in use

“Port 4200 is already in use” while running ng serve Angular CLI command

When you tried to run an Angular Project using “ng serve” command and see error like “Port 4200 is already in use. Use ‘–port’ to specify a different port“.

Solution

First you can investigate whether the port 4200 is already in use. To check that try running the following netstat command in Windows

The PID “4344” is from “ng serve”. If you would like to kill this process, then run the following command.

If you don’t like to terminate the process and wanted to specify a different port, then you can run the following command

This means that you already have another service running on port 4200 and you can either terminate the process or service which is using that port or use the flag “–port” while runnning “ng serve”

The above command would change the URL to something like

http://localhost:8001

Hope this resolves this issue 🙂

Further Learning

References

Leave a Reply

avatar
  Subscribe  
Notify of