IISExpress returns a 503 error from remote machines

会有一股神秘感。 提交于 2019-11-26 23:27:22
vikomall

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

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.

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

Anthony Rizzolo

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.

Nothing worked for me. Finally I found iisexpress-proxy

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

Another solution is ngrok

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.

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

Elrinth

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/

None of the answers above worked for me.

I have had two entries in netsh for the same service

netsh http show urlacl

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://docs.microsoft.com/en-gb/windows/desktop/Http/urlprefix-strings

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!