Back to our insights

How to avoid ‘Port 4200 is already in use’ error with Angular-CLI?

1 minute read - Technology
Share :

If you get this error: ‘Port 4200 is already in use. Use ‘–port’ to specify a different port’, you might have left your Angular development environment without closing the node.js webserver’s port.


Here’s how you can close it without having to reboot your computer or change your application’s port.

Step 1: Find the connection’s PID

netstat -ano | findstr :yourPortNumber

Example with its output:

Then locate the PID (surrounded in red)

Step 2: Kill the process using it’s PID

tskill yourPID

Example:

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:

That’s it.

Let us be part of your transformation.

Let’s talk
This site is registered on wpml.org as a development site. Switch to a production site key to remove this banner.