Coming from XAMPP, using the Apache server, I am used to just test my websites in a networked computer by simply typing IPaddress
:PortNumber
on the address bar of the desired networked computer.
Then while developing with VS2017, I found out that it is not possible by default. While it works fine in the localhost, any networked computer is unable to access the website. What do I need to access to change the settings so that I can expose it to port 8012 rather than 127.0.0.1:8012 ?
I assume that's the problem here.
I was able to solve this problem by changing the binding values in
applicationhost.config
- VS2015 onwards, it can be found inside the individual project folder
%ProjectFolder%/.vs/config/
- In pre-2015 VS, its available in
%USER%/Documents/IISExpress/config/
If you are familar with XAMPP, the setting is similar to %XAMPP%/apache/conf/httpd.conf
*:3940:locahost
, which makes it only available to the computer running VS.<bindings>
<binding protocol="http" bindingInformation="*:3940:localhost" />
</bindings>
<bindings>
<binding protocol="http" bindingInformation="*:3940:*" />
</bindings>
bindingInformation="*:3940:"
may be used instead of bindingInformation="*:3940:*"
If after all this, it still does not work, then it may be a firewall issue as @Mukesh pointed out in his comment.
- Firewall issues can be quickly found out by simply pinging the target device.
- If the ping is successful but the port is not allowed, then open the firewall in advanced mode
- Open RUN (Windows + R)
- Type firewall.cpl
- Click on Advanced Settings
- Click on Inbound Rules
- Create New Rule
- Add your desired port to the rule
- Port > Specific local ports:
3940
> Allow the connection > Check all (Domain, Private, Public) > Give a name to your rule:ExampleRule
> Finish- You can replace
3940
with your desired port number or port range. It is also possible to select all possible ports.- optional: Although nothing really needs to be done in the client computer, you may need to configure your firewall inbound rule to accept all Inbound connections
- If it is not a firewall issue, it can be something else entirely. Maybe you're getting a 400 Error page, or a 503 Error. The following SO questions helped me a lot to tackle those problems (although I had to revert the ACL allowance later). I hope this is useful to someone in the future
- IIS Express Configuration
- Change binding, ACL and Port forwarding
- HTTP 400 Bad Request Error
- Solution to this ^ is here
- 503 Service Unavailable Error
- Sometimes this is solved by simply creating binding entries in
applicationhost.config
- Other times, its the duplicate-binding problem. And you need to remove a binding entry during those times. If you are editing
applicationhost.config
inside the project folder, then it is okay to keep only one site and binding information.- for my particular case, I had to revert this operation
netsh http add urlacl url=http://192.168.10.3:3940/ user=everyone
with thisnetsh http delete urlacl url=http://192.168.10.3:3940/
because I kept getting 502 Bad Gateway error when I tried tunneling.- Things to remember:
- Please remember to properly restart IISExpress after each change. Normally VS does this by itself. Just double check for any running instances.
- Also, always run VS in administrative mode. This usually clears many problems and also allows all sub-processes, such as IISExpress to startup in elevated privilege mode to avoid permission errors.