SHARE:

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

 

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 🙂

Written by

anthonygiretti

Anthony is a specialist in Web technologies (14 years of experience), in particular Microsoft .NET and learns the Cloud Azure platform. He has received twice the Microsoft MVP award and he is also certified Microsoft MCSD and Azure Fundamentals.
%d bloggers like this: