I have a website (MVC3), which for developement is hosted in IIS Express. (I've run into a bug of Cassini Devserver and had to upgrade...) Now, I'm wondering, is it possible to let other machines on my local net (behind router) see the site as hosted on my machine? (e.g. If I write http://my.local.ip:port into a browser on the same LAN as I am will the page load?)
-
1@John Saunders: Did. Not working. – TDaver Mar 08 '11 at 17:30
-
1care to share the results? What does "not working" mean? – John Saunders Mar 08 '11 at 19:29
-
it meant the page didn't load (server not responding), so I'm guessing the IIS Express doesn't answer non-localhost request (like Cassini). But since IIS Express IS a full server it should be able to. – TDaver Mar 08 '11 at 19:58
6 Answers
By default IIS Express serves only localhost requests. To serve external requests edit applicationhost.config
file (located in %userprofile%\documents\iisexpress\config\
) and change localhost
to '*'
or your machine name. (remember for non-localhost binding you must be running as administrator or set URL acl as an administrator and then run iisexpress as non-administrator)
-
1I've located my site in the config xml, and changed `
` to ` `. Then added url acl in admin mode (`netsh http add urlacl url=http://+:44886/ user=\Everyone`). Now, when I press F5 in visual studio, I get "Unable to start IIS Express". – TDaver Mar 12 '11 at 10:00 -
40run this command "netsh http add urlacl url=http://*:44886/ user=Everyone" and try to start it again(press F5). This should work. Following link may also help http://learn.iis.net/page.aspx/1005/handling-url-binding-failures-in-iis-express/ – vikomall Mar 14 '11 at 16:32
-
3fyi, you must restart the service for this to take effect, else you get a 503 error. works perfect for me after svc restart. – Kevin Won Mar 05 '13 at 20:59
-
Url from @vikomall has changed to http://www.iis.net/learn/extensions/using-iis-express/handling-url-binding-failures-in-iis-express – Ciarán Bruen Nov 14 '13 at 15:17
-
2
-
1@CiaranBruen: Both links point to the same page (now, anyway). – B. Clay Shannon-B. Crow Raven Sep 11 '14 at 16:40
-
@vikomall: By "run this command" do you mean in cmd? If so, I'm surprised that mashing F5 does anything after that... – B. Clay Shannon-B. Crow Raven Sep 11 '14 at 16:46
-
I had to add an additional binding in the `applicationhost.config` file in stead of modifying the existing one. Otherwise visual studio keeps creating a different one. And couldn't use * so simply used local IP. Also, had to run VS in administrator – hofnarwillie Mar 03 '15 at 11:37
-
1Note: the user/group "Everyone" has to be localized. I.e. for Swedish Windows, write "Alla" instead. – Kjell Rilbe Mar 17 '16 at 09:11
-
Don't also forget to configure your windows firewall to let the your port pass. – miguelbgouveia Sep 13 '16 at 13:38
Alternatively, you can use something like AnalogX's PortMapper to act as a small loopback proxy to tunnel privately localhost bound ports to publicly open ports.
For example,
- IISExpress is locally bound to localhost:8080
- PortMapper port 9090 is configured to relay traffic to localhost:8080
Effectively, any connection on port 9090 (opened by PortMapper) will be tunneled to localhost:8080; thereby bypassing all the netsh nonsense which can be a pain sometimes.
Below is my configuration:
The benefit of using this proxying method is that it does not permanently expose an open IISExpress port on the local dev box.
Rarely, there are times when I want to open the port publicly for meetings; but most of the time, the port should closed and only be accessible by localhost. Modifying firewall rules on the router every time is a pain. Here's how I have things setup:
- My router firewall forwards 9090 port to PortMapper
- PortMapper only continues proxying the traffic to IISExpress (listening on 8080) only if PortMapper is running.
Note
Make sure to close out all the PortMapper windows for any changes to take effect.
Note 2
As others have described, you might need to adjust the IISExpress bindings for your application in
My Documents\IISExpress\applicationhost.config
project\.vs\config\applicationhost.config
to something like:
<bindings>
<!-- bindingInformaiton format:
IPToBindTo:Port:DNSHostName -->
<!--OLD:
<binding protocol="http" bindingInformation="*:8080:localhost"/>-->
<!--Change '*' to 127.0.0.1 and remove 'localhost' right of the port number
to avoid invalid DNS hostname errors -->
<binding protocol="http" bindingInformation="127.0.0.1:8080:" />
</bindings>

- 8,048
- 5
- 54
- 47
-
The idea is very good (I will surely use this proxy for other scenarios), but it doesn't work in this case. IIS Express just gives you this back when trying to access the site by its IP: `HTTP Error 400. The request hostname is invalid.` – MEMark Aug 13 '13 at 10:04
-
I updated my answer; hopefully that solves your "hostname" invalid error. – Brian Chavez Dec 10 '13 at 21:12
I believe there are three steps to making this succesful:
1) Add a dns entry or hosts entries so other machines can lookup the dev machine's ip address
2) Add a binding to applicationhost.config in %userprofile/documents/IISExpress/Config like so
<site name="MobileDashboard(2)" id="7">
<bindings>
...
<binding protocol="http" bindingInformation="*:yourport#:yourmachinendnsname" />
</bindings>
</site>
3) Run the command found here to allow incoming requests:
netsh http add urlacl url=http://yourmachinendnsname:yourport#/ user=everyone

- 605
- 5
- 14
-
So is this what I need to add to C:\Windows\System32\drivers\etc\hosts:
localhost ...such as: 192.168.125.50 localhost ? – B. Clay Shannon-B. Crow Raven Sep 11 '14 at 17:01
The answer in this thread is great, it just leaves out the firewall exceptions.
netsh advfirewall firewall add rule name="IIS Express (non-SSL)" action=allow protocol=TCP dir=in localport=8000
netsh advfirewall firewall add rule name="IIS Express (SSL)" action=allow protocol=TCP dir=in localport=44300
Sourced from comments @ http://blogs.iis.net/vaidyg/archive/2010/07/29/serving-external-traffic-with-webmatrix-beta.aspx

- 275
- 2
- 11
The Custom Rule trick in Fiddler from http://blogs.microsoft.co.il/blogs/shair/archive/2008/12/15/how-to-use-fiddler-on-localhost.aspx worked for me eventually.

- 9,289
- 3
- 33
- 62
yes you can configure as many sites using iis express for local lan use here is link Accessing local sites from Lan IIS Express which explain how to achieve this.

- 1,445
- 1
- 13
- 18
-
I tried this, it did not work for me. This would be the cleanest answer if I could apply it. The extra application (the one with LAN IP address) does not show up in IIS Express under my site, only the localhost one. Could there be a step missing? I did exit / restart IIS Express. My `applicationhost.config` is looking like `
` – toddmo Apr 11 '15 at 17:37