Web API self host - bind on all network interfaces

Just change the base address like this

        var baseAddress = "http://*:9000/"; 
        using (WebApp.Start<Startup> (baseAddress)) 
        {
            Console.WriteLine("Server started");
            Thread.Sleep(1000000);
        }

And it should bind correctlly to all interfaces.


If you get access exceptions, please DO NOT start Visual Studio as admin user. Add an URL reservation instead. The following example assumes that you want to open port 9000 as HTTP service on all ports & hostnames (http://+:9000/) without any user restriction.

Start a command console window as administrator and execute:

netsh
netsh> http add urlacl url="http://+:9000/" sddl=D:(A;;GX;;;S-1-1-0)

The SDDL translates to "all users" from your current domain / machine.

Modify your code accordingly:

var baseAddress = "http://+:9000/";
using (WebApp.Start<Startup> (baseAddress)) 
{
  // your code here
}

You can delete the reservation by running:

netsh
netsh> http delete urlacl url="http://+:9000/"

However, Microsoft recommends to avoid Top-level wildcard bindings, see:

  • https://docs.microsoft.com/en-us/windows/win32/http/add-urlacl

For more information about the difference between http://*:9000/ and http://+:9000/ see:

  • What does a plus sign mean in a http url? -> http://+:80