194

I'm attempting to test a website I have running in a local IISExpress instance with some other machines / devices on my local network. I am running Win7 Pro.

When I first attempt to browse to my machine from another machine on my local network segment, I get a 400 error: Hostname is invalid.

I understand that I need to grant remote access to the ACL with a command on the elevated command prompt like:

netsh http add urlacl url=http://mymachinename:50333/ user=everyone

Now I get a 503 service is unavailable error.

Windows Firewall is currently shut off, and I am able to browse my local IISExpress instance with the address http://localhost:50333

What is the final piece to this configuration puzzle?

Jeff Fritz
  • 9,821
  • 7
  • 42
  • 52
  • 1
    What happens if you browse to `http://mymachinename:50333/ ` from *your* computer? – Colonel Panic Apr 03 '13 at 13:03
  • 1
    The problem has been resolved. See the accepted answer from vikomall – Jeff Fritz Apr 08 '13 at 18:33
  • 1
    Deeper discussion of this here: http://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx – Chris Moschini Apr 17 '13 at 01:09
  • 3
    You can install our free VS extension 'Conveyor' to get around this issue https://marketplace.visualstudio.com/items?itemName=vs-publisher-1448185.ConveyorbyKeyoti – Jim W Mar 26 '18 at 04:34

10 Answers10

280

It looks like you are missing a binding information entry in applicationhost.config file.

  1. Open your applicationhost.config file. Possible locations are:

    • %userprofile%\Documents\IISExpress\config\applicationhost.config
    • $(solutionDir)\.vs\config\applicationhost.config (VS2015)
    • Failing that, inspect the output from iisexpress.exe to be sure.
  2. Locate your WebSite entry and add following binding with your machine name.

         <binding protocol="http" bindingInformation=":50333:your-machine-name" />
    
  3. Restart IIS Express

fiat
  • 15,501
  • 9
  • 81
  • 103
vikomall
  • 17,379
  • 6
  • 49
  • 39
  • Hooray! After almost 2 hours trying to get it working between a Windows 7 virtual machine running under Parallels Desktop 6 and my Mac OS host, I finally got it working. I was missing this final piece in the puzzle. Awesome. Now I can test my ASP.NET MVC 3 site running in IIS Express in Mac OS too. – Leniel Maccaferri Apr 23 '11 at 03:32
  • 1
    Just to mention: this post provided a good amount of info related to the configuration I needed: http://blogs.iis.net/vaidyg/archive/2010/07/29/serving-external-traffic-with-webmatrix-beta.aspx – Leniel Maccaferri Apr 23 '11 at 03:37
  • 9
    Never mind. Visual Studio created a duplicate config entry for the item. I removed it and it worked. – marknuzz Oct 26 '12 at 23:10
  • 3
    IIS Express doesn't always use the config file at that path. Read the output from `iisexpress.exe` carefully to see which config file it is using. – Colonel Panic Apr 03 '13 at 13:17
  • 6
    Key point item 3, restart IIS Express! Locate the icon in your system-tray and stop it to force it to restart. Not sure if there is a more elegant way. But this worked for me. Thanks! – The Senator May 23 '13 at 13:33
  • 2
    And another reason, HTTPS ports must be in the range of 44300-44399 to use the self-signed certificate provided by IIS express. In other words port 44900 will not work without additional configuration. http://www.iis.net/learn/extensions/using-iis-express/handling-url-binding-failures-in-iis-express – cstick Jun 03 '14 at 16:05
  • 10
    If you are too lazy to add every hostname/ipaddress combination use a * instead of "your-machine-name" – StarQuake Oct 06 '14 at 10:45
  • Launching from command prompt, I found that when I used the /path option in iisexpress.exe instead of /config, IIS Express would make a copy of my config and change the binding to localhost. – mek363 Jan 10 '16 at 16:06
  • 1
    For me, `` worked. I used `ngrok http 5001` to create the tunnel. The key piece for me was modifying the config here: `$(solutionDir)\.vs\config\applicationhost.config` – Elmer Thomas Jul 27 '16 at 14:24
  • 8
    One more hint: If you right-click on IISExpress' systray icon, you can select "Show all applications" which will open up a dialog showing all applications you're currently running locally. Right-click on the desired application (don't left-click or it will open the browser), then you will see "Path" and "Config" below. Left-Click on "Config" and it will open up the related Applicationhost.config file where you need to add/edit the bindings as described above. That is an easy way to locate the current configuration. – Matt Nov 22 '16 at 14:48
  • I have Windows 8.1 and IIS Express applicationhost.config file's location was: C:\Windows\System32\inetsrv\config – Ivan Santiago Oct 02 '18 at 13:06
  • applicationhost.config also can live in `$(solutionDir)\.vs\Core\config\applicationhost.config`. I had to update this one before the 503 went away – fepiv Apr 11 '19 at 19:48
  • 1
    After following your instructions from Visual Studio Debug IIS, my site down and even after reverting it is not coming up – SimpleGuy Jul 28 '20 at 01:44
35

There was only 1 thing that worked for me.

using *:portnumber:* was no good. Yes, after doing that and making sure the Windows Firewall was open, I could connect to the port, but I still got the "503" error.

I tested a few things locally, and discovered that only http://localhost worked. Using the real IP address (not 127.0.0.1, but, for instance, 192.168.1.50), still returned a 503 even on the local machine. I tried using the real host name in the bindings, but IIS Express refused to start. This may actually have something to do with how the host name was being resolved. I didn't explore that further.

Finally, I ended up using this configuration:

<binding protocol="http" bindingInformation="*:53351:localhost" />
<binding protocol="http" bindingInformation="192.168.1.50:53351:*" />

In that way, I was able to connect from a remote machine using http://192.168.1.50:53351.

The Lizard
  • 507
  • 5
  • 7
  • 1
    I hit this exact error, but did not want to hard-code the current IP into the config, since it can change. I found the wildcard works on the IP and hostname parts, so I ended up with: `` ` ` edit: really tried to understand SO markdown, I quit :). – Brian Barker Jun 04 '17 at 20:09
20

After wasting more than 3h on such a full subject I decided to share my setup with you. My configuration is Visual Express 2012 for Web update 4 on windows 8. This was my first come back to MS VS since studies (at least 8 years) and now I'm sure that linux rules. On django this kind of setup took me 10min of searching documentation.

  1. turn off firewall for testing

    netsh advfirewall set allprofiles state off
    
  2. setup bindings in my case local address is localIP=192.168.1.102 (because links can not contain nonnumeric domain, use it below instead of mylocaldomain.com, see stackoverflow policy) in Documents\IISExpress\config\applicationhost.config

    <bindings>
        <binding protocol="http" bindingInformation="*:53351:mylocaldomain.com" />
        <binding protocol="http" bindingInformation="*:53351:localhost" />
    </bindings>
    
  3. add autorun for ISS Express start service automatically

    <site name="NeuronCharts" id="2" serverAutoStart="true">
    
  4. Add some weird rules to http server (I still do not know if this is nesseary)

    netsh http add urlacl url=http://mylocaldomain.com:53351/ user=everyone
    
  5. run IISExpress manually not from VS IDE

  6. you will see that ISSExpress is registering bindings
  7. run browser http://mylocaldomain.com:53351 if it is working then we can add firewall rule
  8. add firewall rule

    netsh advfirewall firewall add rule name="IISExpressWeb" dir=in protocol=tcp localport=53351 remoteip=any action=allow
    

set remoteip to any if you want to access you server from outside world if you want to access for local network use localsubnet

  1. start firewall

    netsh advfirewall set allprofiles state on
    
  2. check again if everything is working on local and public ip

Wish you luck

Rafal

Rafal
  • 209
  • 2
  • 3
  • 3
    This caused IIS Express to no longer run on Win8 with VS2013 without running VS2013 as Administrator. It's caused by IIS Express now trying to open to external traffic as a result of the netsh command. I also was never able to actually get it to serve that traffic; I'd get a 503. To reverse the problem caused by the netsh command in this answer, run this from a Command Prompt running as Administrator: `netsh http delete urlacl url=http://*:55416/` (replace port with your port) – Chris Moschini Dec 15 '14 at 15:46
  • fwiw - I don't need step 4 (the netsh call that @Rafal isn't sure is necessary) and, although I don't need the "localhost" binding in step 2 to run the VS2013 projects in my solution, the front end loads *significantly* faster when that "localhost" binding is left in place. – lukkea Jun 23 '15 at 17:18
  • I found that following the above instructions still resulted in 503 using `localhost`. I found that the guest (Windows) machine name needed to be in the bindings in `applicationhost.config`, and on the host (Mac) the guest machine name needed to be mapped to `127.0.0.1` in `/etc/hosts`. Only then did a request to the guest machine on the host succeed. – Matt Jan 10 '16 at 19:55
  • One addition to step 5. Use iisexpress.exe /siteid:id where id is the value of your site's id attribute in setting, otherwise it will start the 1st site. – Mudit Jain Aug 29 '16 at 23:57
10

Found the problem had to do with a bad urlacl mapping. To figure this out:

netsh http show urlacl 

and look for things like http://+:80/ or the port you are binding to.

Then use

netsh http delete url=<the url from the list>

This fixed the problem for me.

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
Anthony Rizzolo
  • 101
  • 1
  • 2
8

Nothing worked for me. Finally I found iisexpress-proxy

See my answer https://stackoverflow.com/a/33623399/631527

Another solution is ngrok

Toolkit
  • 10,779
  • 8
  • 59
  • 68
  • Amazing! I tried all those other solutions and they didn't work either. "Bad request" or "Service unavailable". Too complicated. I installed the node module and ran it, it instantly works!! – TetraDev Jan 29 '16 at 22:17
  • WORKS! holy! Thank you! – Don P Nov 30 '18 at 21:31
  • check out ngrok also – Toolkit Dec 01 '18 at 07:35
  • 1
    It SIMPLY works like a charm with ngrok! It is weird having to route first from localhost to iis-proxy and then from proxy to ngrok, but hey, worked!. For example, I have my iisexpress on port `3028`. I ran `iisexpress-proxy 3028 to 12345` and then `./ngrok.exe http 12345`. – Reuel Ribeiro Apr 09 '19 at 19:16
  • @TetraDev, the "Bad request" or "Service unavailable" was because the host header received when accesing localhost from ngrok was not a localhost one as explained [here](https://www.twilio.com/blog/2014/03/configure-windows-for-local-webhook-testing-using-ngrok.html) – Dani Dec 31 '19 at 14:57
4

What helped me, was right clicking the 'IISExpress' icon, 'Show All applications'. Then selecting the website and I saw which aplicationhost.config it uses, and the the correction went perfectly.

IISExpress configuration

Emmanuel
  • 7,574
  • 3
  • 24
  • 22
1

The problem is updating the applicationhost.config file inside the web folder instead of the solution's. The solution config file is the one to change

1

Regarding Anthony Rizzolo's answer: in Windows 8.1, I had to type like this:

netsh http delete urlacl url=<the url from the list>

For example:

netsh http delete urlacl url=http://+:8689/
Pang
  • 9,564
  • 146
  • 81
  • 122
Elrinth
  • 51
  • 3
1

After solution of @vikomall don't forget to start VS as adminisrator. This fix it for me.

Rapido
  • 301
  • 4
  • 12
0

None of the answers above worked for me.

I have had two entries in netsh for the same service

netsh http show urlacl

enter image description here

One using a strong wildcard, the other one using a weak wildcard.

Removing the one with the weak wildcard did the job.

More about the strong and weak wildcard in the context of netsh

When the host element of a UrlPrefix consists of a single plus sign (+), the UrlPrefix matches all possible host names in the context of its scheme, port and relativeURI elements, and falls into the strong wildcard category.

When an asterisk (*) appears as the host element, then the UrlPrefix falls into the weak wildcard category. This kind of UrlPrefix matches any host name associated with the specified scheme, port and relativeURI that has not already been matched by a strong-wildcard, explicit, or IP-bound weak-wildcard UrlPrefix. This host specification can be used as a default catch-all in some circumstances, or can be used to specify a large section of URL namespace without having to use many UrlPrefixes.

https://learn.microsoft.com/en-gb/windows/desktop/Http/urlprefix-strings

matcheek
  • 4,887
  • 9
  • 42
  • 73