Failed to register URL “http://localhost:64831/” for site “Development Web Site” application “/”. Error description: Access is denied. (0x80070005)

Diagnose

Port exclusions can be reserved by Docker or Hyper-V that conflict with the port used by IIS Express for a given project. You can verify this your issue with the following command to list the excluded port ranges.

netsh interface ipv4 show excludedportrange protocol=tcp

Protocol tcp Port Exclusion Ranges

Start Port    End Port
----------    --------
     49787       49886
     50000       50059     *
     50160       50259
     50260       50359
     51212       51212     *
     56464       56563
     56580       56679
     57010       57109
     64808       64909     

In this case the range 64808 - 64909 is the cause and IIS Express will not be able to use it.

Fix

Step 1. Release the reserved port by restarting the Host Networking Service (HNS)

The Host Networking Service (HNS) attaches container endpoints to a network. Restarting the HNS service may release the reserved port.

As an administrator account restart the hns service.

restart-service hns

If the restarting HNS does not release the reserved port then turn off Hyper-V

  1. Navigate to Windows features on or off
  2. Turn off the Hyper-V feature
  3. Reboot

Step 2. Reserve the port

Reserve the port using the command:

netsh int ipv4 add excludedportrange protocol=tcp startport=64831 numberofports=1 store=persistent

If this fails with the message The process cannot access the file because it is being used by another process. Stop winnt and reserve the port using the following commands. You may need to also stop Docker.

net stop winnat
netsh int ipv4 add excludedportrange protocol=tcp startport=64831 numberofports=1 store=persistent
net start winnat

Run the following to verify the port has been reserved:

netsh interface ipv4 show excludedportrange protocol=tcp

Protocol tcp Port Exclusion Ranges

Start Port    End Port
----------    --------
     49787       49886
     50000       50059     *
     50160       50259
     50260       50359
     51212       51212     *
     56464       56563
     56580       56679
     57010       57109
     64831       64831     *

* - Administered port exclusions.