45

Ok, so here is the scenario:

I have computer A inside my local network running IIS 7. I added a new website, let's say samplesite.local, through IIS Manager, and edited the hosts file inside %systemroot%\system32\drivers\etc\ with this new line:

127.0.0.1 samplesite.local

So, in a browser running in computer A, if I type samplesite.local in the address bar and hit Enter, everything works fine. I can access the website.

Now I wanted to access this website from other local computers, say, computer B or an iPad, not from the outside world, but from inside the same local network.

Any thoughts?

Edit: Computer A's IP is 192.168.1.100, and samplesite.local is running on port 80. However, if I type 192.168.1.100 in any computer's browser's address bar, I'm taken to the default IIS website, the one with the IIS logo, whose physical address is C:\inetpub\wwwroot\, not to samplesite.local.

fduayer
  • 770
  • 1
  • 7
  • 23
  • Were you able to resolve this? I have the same problem – Jackson Jul 31 '14 at 09:32
  • 1
    @Jackson You might not need to do anything, since you are using the same network. Maybe, the best way to check, is from the hosting machine, switch off the windows firewall, and try to access again – Jacky Feb 06 '17 at 07:34

5 Answers5

53

Add two bindings to your website, one for local access and another for LAN access like so:

Open IIS and select your local website (that you want to access from your local network) from the left panel:

Connections > server (user-pc) > sites > local site

Open Bindings on the right panel under Actions tab add these bindings:

  1. Local:

    Type: http
    Ip Address: All Unassigned
    Port: 80
    Host name: samplesite.local
    
  2. LAN:

    Type: http
    Ip Address: <Network address of the hosting machine ex. 192.168.0.10>
    Port: 80
    Host name: <Leave it blank>
    

Voila, you should be able to access the website from any machine on your local network by using the host's LAN IP address (192.168.0.10 in the above example) as the site url.

NOTE:

if you want to access the website from LAN using a host name (like samplesite.local) instead of an ip address, add the host name to the hosts file on the local network machine (The hosts file can be found in "C:\Windows\System32\drivers\etc\hosts" in windows, or "/etc/hosts" in ubuntu):

192.168.0.10 samplesite.local

razz
  • 9,770
  • 7
  • 50
  • 68
  • 1
    What to do, if the website isn't located inside `wwwroot` folder. Like it's been running using **Visual Studio** – Deepak Yadav Mar 24 '17 at 05:20
  • 5
    Can I access using different port? e.g. 192.168.0.10:8000 – harryfeng Jun 02 '17 at 19:44
  • 2
    Yes, just open the port on the firewall of web server, then add port 8080 to the end of the address, just like your example: 192.168.20.22:8080 – SamAndrew81 May 18 '18 at 04:21
  • 1
    Hi can anyone tell me if it is possible to use the hostname to access the website from a local area network. Say like a different computer on the local network? If possible please let me know how. – prkash Sep 12 '18 at 07:56
  • my machine remote pc just keeps resolving to "localhost" :( – djack109 May 31 '20 at 18:48
  • Hi, can i access local with domain from other computer? – Diale Oct 26 '20 at 01:50
  • I ran asp.net core 5 web api in vs 2019 with `"applicationUrl": "http://localhost:5000/"`, bit I still see "Bad request-invalid hostname", when go to *computer ip*/*pagename* by my phone in one local network. – EgoPingvina Jul 26 '21 at 13:28
  • after adding ip and hostname in host file still unable to access on another computer with same LAN with host name? (with IP it is working). Any other solution? – Zubair Khakwani Dec 20 '22 at 10:54
26

do not turn off firewall, Go Control Panel\System and Security\Windows Firewall then Advanced settings then Inbound Rules->From right pan choose New Rule-> Port-> TCP and type in port number 80 then give a name in next window, that's it.

Morteza
  • 366
  • 3
  • 7
12

Control Panel >> Windows Firewall

Advanced settings >> Inbound Rules >> World Wide Web Services - Enable it All or (Domain, Private, Public) as needed.

Pratik
  • 129
  • 1
  • 2
  • 1
    Can you go into more detail on why and how this resolves the issue and especially what "as needed" would be in the actual case? – ImportanceOfBeingErnest Oct 28 '16 at 14:50
  • I was struggling making my local machine IIS available to other machine on my network, so this is what I did to get it resolved after verifying with my admin. I tried some of the other solution on the blog and it didn't work for me so I wanted to share my solution. So my basic understanding is in order to access to your any inbound request to your machine it has to go through firewall unless its disabled. In my situation since I wanted access IIS to I only enabled my IIS to be available on my network. There are other solutions that made sense but didn't work for me. – Pratik Dec 08 '16 at 17:55
  • 1
    I had this in Windows 10. The issue was the 'domain' firewall, for which the setting has moved. I had to go 'Start' > type "Windows Defender Settings" > Firewall and Network Protection, then turn off 'Domain network'. Even though I had opened port 80, this still needed doing to get it to work. – JsAndDotNet Jun 18 '18 at 10:07
4

Find the local IP address of computer A and find the port that your website is running on. Then from computer B open a web browser and go to IP:port. Example: 192.168.1.5:80 if computer A's IP is 192.168.1.5 and your website is running on port 80

John Dorian
  • 1,884
  • 1
  • 19
  • 29
-6

Control Panel >> Windows Firewall >> Turn windows firewall on or off >> Turn off.

Advanced settings >> Domain profile >> Windows firewall properties >> Firewall status >> Off.

M. Salah
  • 671
  • 7
  • 10