Home » How To » How To Reserve a Port or Port Range in Windows 11 & 10

How To Reserve a Port or Port Range in Windows 11 & 10

Want to reserve a specific port or port range so that Windows or other apps don’t automatically use them? Here’s how.

If you are someone who needs a specific port or a port range to be free so that you can use it for yourself, you need to manually reserve it. Otherwise, Windows or any other application might use it, leaving you stranded. For example, I was developing a Python script that needed port 8000. But, often, that specific port is being automatically assigned by Windows for other tasks. So, I manually reserved that port so that Windows doesn’t automatically assign it to other apps. As you can guess, that solved a lot of headaches for me, since I no longer had to edit the script to assign a new port.

In this quick and easy guide, I will show you how to reserve a port or port range in Windows 11 and Windows 10 so that your system doesn’t automatically assign it to other apps or system activities. Let’s get started.

Before You Start

  • Administrator rights are required to reserve ports in Windows 11 or 10.

Steps to Reserve a Port or Port Range in Windows 11 & 10

  1. Right-click the Start button.
  2. Select “Terminal (Admin)” or “Windows PowerShell (Admin)”.
  3. Run the following command to reserve a specific port. Replace “8000” with the actual port number. netsh int ipv4 add excludedportrange protocol=tcp startport=8000 numberofports=1
  4. To reserve a port range, replace “8000” with the actual port number, change the “numberofports” count, and run the command. netsh int ipv4 add excludedportrange protocol=tcp startport=8000 numberofports=6
  5. That is it. With that, you’ve reserved the port or port range.

Detailed Steps (With Screenshots)

First, right-click the Start button on the taskbar or press the “Windows key + X” shortcut. Next, select the “Terminal (Admin)” option on Windows 11 and the “Windows PowerShell (Admin)” option on Windows 10.

In the Terminal/PowerShell window, run the following command to reserve a specific port. Don’t forget to replace “8000” in the command below with the actual port number you want to reserve.

netsh int ipv4 add excludedportrange protocol=tcp startport=8000 numberofports=1

Now, if you want to exclude a port range, you just need to update the “numberofports” number. For example, to exclude a port range of 8000, 8001, 8002, 8003, 8004, and 8005, you need to change the “numberofports” number to 6. So, the command looks like this:

netsh int ipv4 add excludedportrange protocol=tcp startport=8000 numberofports=6

Once you do this, you can close the terminal/PowerShell window.

To unreserve a previously reserved port, run the following command. Don’t forget to replace the dummy port number “8000” with your actual port number.

netsh int ipv4 add excludedportrange protocol=tcp startport=8000 numberofports=1

Also, to unreserve a port range, update the “numberofports” number. This is how the command looks like

netsh int ipv4 delete excludedportrange protocol=tcp startport=8000 numberofports=6

That is all. It is that simple to reserve or unreserve a port or a port range in Windows 11 and Windows 10. If you have any questions or need help, comment below. I’ll be happy to assist.

Leave a Comment

Your email address will not be published. Required fields are marked *