• fr
  • 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 🙂

    Let's get acquainted
    Want to learn more and/or collaborate with us?

    We can't wait to hear from you.