Numerous hours I spent thinking about how to enable external access to an IIS Express website from devices other than a localhost. Even more hours I spent “googling and stackoverflowing” the problem - finally, the search is over and all the efforts has paid off!

Here is how you can configure your IIS Express to run on an external IP address without any 3rd-party software, messing with registry and other doubtful techniques, just Windows and a bit of scripting.

The Solution

First, let’s assume you run your web site on localhost:60000 and you want your service to be accessible from your wifi IP address, say… 192.168.1.50:3000. You need to run the following commands in admin console (or powershell):

PS C:\Windows\system32> netsh
netsh>interface
netsh interface>portproxy
netsh interface portproxy>add v4tov6 listenport=3000 connectaddress=[::1] connectport=60000

Check that the configuration has been stored:

netsh interface portproxy>dump

#========================
# Port Proxy configuration
#========================
pushd interface portproxy

reset
add v4tov6 listenport=3000 connectaddress=[::1] connectport=60000


popd

# End of Port Proxy configuration

Now run your IIS Express and try opening http://localhost:3000/ or http://192.168.1.50:3000/, it should all work!

Explanation

Now, in case you are curiuos why it worked while all other solutions you tried didn’t…

  1. changing the applicationhost.config
  2. fix ACL and run VS under administrator
  3. use a nodejs port-forwarding proxy
  4. some other thing - please let me know in the comments…

I’m not so sure about why #1 and #2 didn’t work for me, but I’m actually glad that I found a solution that does not involve running Visual Studio as an admin or messing with HTTP.sys configuration. That may be the preferred and supported way to make IIS Express to serve sites externally but there is too many moving parts in those solutions, something will have to break eventually.

So.. on to the real solution. I think the solution #3 didn’t work for me because the proxy expects all ports to be on IPv4 interface. Apparently Windows 10 considers the localhost to be a local IPv6 address [::1]. You can easily see this if you open TCPView when your IIS Express is running:

IIS Express running on TCP6 port

As you can see IIS Express is listening for connections via TCPV6 meaning it will not respond if you call it via 127.0.0.1:60000. The address localhost however resolves to an IPv6 address, that’s why your browser is able to open a website via localhost:60000.

So in order to access your localhost-based website from other devices on your network basically you need to forward some free TCPV4 port on your network interface to the ip:port your IIS Express is running at, in my example it’s [::1]:60000.

This is exaclty what I did there in netsh commands:

add v4tov6 listenport=3000 connectaddress=[::1] connectport=60000

adds a port-forwarding rule from a TCPV6 60000 port to TCPV4 3000.

What I like the most about this is that:

  • this solution does not require additional software to be installed, netsh is an 100%-Windows thing
  • it is persistent, meaning you configure it once and the port-forwarding will be there until you cancel it in netsh.

This is it. Hope it helped you. Let me know if it did in the comments! :)