How to free port on Windows?

System Administration

So… All worked well, you were testing your website locally on some port and then suddenly it stopped working and you got an error that this URL can not be visited because this port is in usage. Can happen also if you have Angular local website, .NET local website in development…

So, how you can get rid of this?

Usually, these three commands will help you (in example is port 4200 – replace it with your own):

  1. net stop winnat
  2. netsh int ipv4 add excludedportrange protocol=tcp startport=4200 numberofports=1
  3. net start winnat

Second command just put your port (4200 in this example) in excluded list, so it will be not used by any app.

You can just say “Thanks” or buy me one beer 🙂