Accessing Websites on a Local Network (LAN) Web Server

There are a number of different ways that local websites can be viewed from other computers (running Windows, Mac OS X, Linux) and mobile devices (iPads, iPhones, Android phones, etc), that are all connected within the same LAN (local network).

To get every LAN connected computer and mobile device to find and connect to a local website, you have these options:

Use the LAN IP of Server

Connect directly to the server via its LAN IP address, using that IP in the URL:

For this to work, the LAN IP address must be assigned as one of the website’s Domain Aliases, and all redirects from Aliases to the Primary Domain Name must be turned off.

Downside – as only 1 IP address is assigned per NIC (network card), only 1 website can be accessed.

Use the LAN host-name of Server

Connect to the server via its LAN host-name (computer name), using that host-name in the URL:

For this to work, the LAN host-name must be assigned as one of the website’s Domain Aliases, and all redirects from Aliases to the Primary Domain Name must be turned off.

Downside – as only 1 host-name (computer name) is assigned per computer, only 1 website can be accessed. Also, there might be issues with some non-Windows devices, such as the iPad, which either don’t inter-operate (work with) WINS and NetBIOS or require further configuration.

Use a LAN-wide Hosts file Set Up

Connect to the server by using LAN-wide (global) Hosts files…

This is done by editing every LAN systems’ Hosts file with entries that resolve each and every website’s domain-name and aliases to the LAN IP of the server: domain1.alias1 domain1.alias2 domain2.alias1 domain2.alias2 domain3.alias1 domain3.alias2

This way all the other LAN systems know to which IP address to send the request to when the is used in the local Browser.

Downside – while this will work on Windows, Linux, and Mac OS X, this will not work on most mobile devices unless they are jail-broken / rooted (as you can’t edit their Hosts file).

Hosts file path: C:\Windows\system32\drivers\etc\hosts

Use Registered Domain Names

Connect via any website’s domain-name, as long as that domain-name is:

  • Registered (bought and paid for on Namecheap, GoDaddy, etc)
  • And has a DNS “A” record set (resolved) to either the LAN IP of the server (ex: or the Public IP of the Router (via the domain Registrar’s DNS servers).

* It’s perfectly valid to resolve a domain-name to a local LAN IP address.

If you only have 1 registered domain name, you can use its sub-domains to represent your different local websites, by using a wild-card (*) / catch-all DNS record. This way all * requests, regardless of what they are, will always be resolved to your LAN IP or Public IP. And once that request reaches your web server, the web server will match the to the proper website. The downside of this is that every website’s domain-name must use a common base (which can make the full address long).

Use a WiFi Router that’s capable of DNS Masquerading

Some Routers are supported by 3rd-party firmware such as the OpenWRT and DD-WRT (2) projects.

Both OpenWRT and DD-WRT are able to inject custom domain-name to IP address resolves via their own internal Hosts files and/or internal bundled DNS Masquerading software such as DNSmasq.

This is probably the best option as ALL WiFi connected computers (regardless of OS) and mobile devices (everything from iPads to Android phones) will be able to connect to each and every website… Without configuring anything or doing anything to those computers and devices.

Use Own DNS Servers

Local networks (that are behind a typical wifi Router) use outside DNS servers, which “resolve” (convert) domain names to IP addresses.

Typically, the Router gets the addresses of 2-4 DNS servers from your Internet Provider (via a protocol called DHCP), and acts as the middle-man, for domain name resolve requests, between the computers and devices within the LAN, and the external DNS servers.

These external DNS servers are unable to answer and resolve requests for your “virtual” (non-registered) domain names to your locally hosted websites and their LAN IPs.

You can however, via your Router settings, switch-over these DNS servers with your own local DNS server, which will be able to resolve all “virtual” (fake) domain names, and wildcards (ex: *.local), to the server’s LAN IP address.

There are several options for DNS Servers for Windows, and Linux.


On some mobile devices, you can set them to use an HTTP Proxy server, that will then custom-resolve the domain-name to the LAN IP address. This gets around the problem of not being able to edit the device’s Hosts file without jail-breaking or rooting it. But you’ll need one computer running the proxy server software. On Windows, you can use the Fiddler Proxy to set this up.

Mobile devices have to be connected to your WiFi to be able to access the server via the LAN IP address. Otherwise, you must use a registered domain-name that has a DNS record resolving the domain-name to the the Public IP of the Router (which then “port-forwards” from WAN:80 to LAN:80 of server).

LAN IPs are usually reassigned/changed after reboot or power-off of the LAN connected computers and devices and/or the Router. You’ll have to go into the Router’s configuration and settings, and make sure to manually assign the same LAN IP to the same LAN system (by assigning that LAN IP to the server’s MAC address).

When a request comes in to the web-server for a domain-name or IP address that is not assigned to any website, the first Apache Virtual Host (DefaultWebsite, localhost) gets returned.

When accessing the server directly via an IP address, you’ll only be able to access 1 website (the website that has that IP assigned as a Domain Alias)… Unless you run each website on a separate port number (8080, 8081, etc). *Some Apache configurations/setups and some PHP web-app scripts might not work correctly, as they expect regular port 80 access.

While most mobile devices (including iOS and Android devices) have a Hosts file, those devices have to be jail-broken/rooted, and/or you have to go through complicated steps to modify their Hosts file. * If you edit the Hosts file, make sure you save it in it’s original encoding: ANSI.

Running your own DNS server is not recommended as it could be complicated to set up and operate, and the system it’s on has to always be On for everything else to work. If you do run your own DNS, you’ll need to set it’s LAN IP in the Router’s settings and make sure no other DNS servers are used (by the Router). DNSMasq is the recommended choice.

You can host multiple websites under 1 main domain-name/website by treating the other websites as folders: C:\WampDeveloper\Websites\\webroot\other.domain\
How do I modify my hosts file?

* Make sure to turn off any redirects of the Domain Aliases to the Primary Domain Name (*select website in WampDeveloper’s Websites Tab, click Settings; or just create a website with the LAN host-name as the Primary Domain Name, and the LAN IP as one of the Domain Aliases).

* Make sure to open (on the web-server) the Windows Firewall inbound port 80 (http) and 443 (https) connections (TCP and UDP). Windows Firewall will block these by default.

* If you are resolving domain-names to the Public IP (of the Router), make sure to update the Router’s settings to “port forward” incoming port 80 (http) and 443 (https) requests to the proper LAN IP of the web-server.

20 thoughts on “Accessing Websites on a Local Network (LAN) Web Server”

  1. If you are working behind a Corporate LAN that has each system’s IE (browser) configured to use the corporate Proxy (for security reasons), to be able to access the website via it’s, you’ll need to either:

    1. Edit IE’s settings to exclude * from the Proxy.

    2. Or use the already excluded format (no dot domains, or maybe *.local) as the website’s Primary Domain Name or Domain Aliases (with redirects turned off).

    Otherwise, you won’t even be able to access the website locally (from the same system the server is on), as the Proxy will attempt to resolve the itself to an IP address using outside DNS instead of Local DNS (which resolves the domain name to

    1. I have a WebApi which is hosted on my machine IIS and I am able to get the results using for e.g.
      as well as

      since I have defined both bindings in my IIS main web site settings
      My main web site is other than the Default Web Site.

      Now I am able to get results in my Android Emulator using the
      2nd URL and not the first one that is I get results

      But not on device (in my case it is a Samsung Galaxy S phone)
      I am not sure how to make the API work on the device as well.
      Do I have to detect what Android configuration I am running and then give the appropriate WebAPI url or
      is there any other way just by manipulating/changing the bindings information in
      the ApplicationHost.config (but that I would assume is only for the Default Web Site?)
      Any help is appreciated.


  2. I’ve got a Wi-Fi dongle and installed its driver to Win7 Ultimate Service Pack1 on 64 bits. I have installed the AppServ (Apache + MySQL) and it is already responding under the name “localhost” for

    I want to redirect (let’s say) to Then, I edited the Windows’ HOSTS file and placed the instruction properly. But, it is not working. I flushed the DNS cache as suggested and nothing worked. As I am using a proxy, I had to exclude the URL from the proxy list. Then, it worked locally!


    … when I try to access it through Wi-Fi on my iPhone… then, it is impossible to access it. It works if you type the IP address, but not if you write the alias or URL.

    As far as I’ve read, this could be the HOST file on iOS, but my device is Jailbroken. Anyway, is there a way to redirect requests to to my localhost on Windows 7?

  3. Hi,
    I would like to know, if I have a web server on a linux
    embedded systems, that it works fine with localhost:8080 or the LAN IP adress, and it is connect via dongle WIFI usb, IF is it possible to see this local host via ethernet (eth0) in other PC.
    I mean, I want to see in a really local way this web server, through another network interface, by connect this device to my laptop, without a LAN network, only PC- DEVICE

    could you help me with that.

    thank you.

  4. Hi,

    As u have suggested I have tried out all, but when i am trying to access the server from the browser, I am getting the error “401 UNAUTHORIZED” but when I am try to ping the systems both ways the communication is possible but when i try to access the server from browser i am getting that error,(both the systems are on the same LAN).

    Thanks in advance

    Thanks and regards

    1. Sounds like you are accessing the Router/WiFi-Modem instead of the LAN server…

      A “401” code is usually what you get back when you access a URL that requires a username/password.

  5. From my server, i am trying to hit a webserver running with an I.P. address, port 80 and find that Web Server’s Type or Name & add the details to any files.

    I know that this server is UP and running.
    I am running Debian.
    How can i do that?

    1. 169.254.x.x are not reachable IP addresses. This IP range is assigned to the interface when DHCP is not working (that would normally assign a routable LAN IP and/or a Public IP).

      The above only works locally on special links and used for special purposes (such as EC2’s meta-data).

      For local LAN access you need a 192.168.x.x IP.

  6. sir i have a local website …accessible from all device in the same network even with the global ip address …but when i access it from other networks via global ip address do not connects ..consider port forwarding working fine ..

  7. I got the similar question, like the one asked by Carlos on February 4, 2016 at 4:25 am, as follows :

    I setup an Apache web server on my Windows 8.1 PC. And I used my Android phone to share the WiFi Station with my PC to let it (the PC running the Apache web server) access the internet. My PC got the local ip from the WiFi Station of my phone. I can acess the default home page (index.html) of my Apache web server with the browers (on my PC and on the phone) by typing :

    I haven’t subscribed a website & domain name from the DNS supplier yet. On other people’s PC (or phone) connected to the internet via other ISP, is there any way to ping my PC with the public ip and local ip detected on my PC ; if I use a browser, what should I type to access the default page of my Apache web server running on my PC ? Do I need to setup the config/host file on the router or the DNS server connected to my phone first ? If yes, may you provide the practial procedure for how to check and setup on my Winodws 8.1 PC ?

    Thanks in advance.

    Best regards,

    1. You will need to figure out how to edit/modify the phone’s routing table or application to forward all incoming requests for its (phone’s) IP address port 80 to the LAN IP port 80…

      Right now the only thing reachable from outside is the phone’s IP address. So you need to forward all requests that do come in on that address, onto the LAN IP.

  8. Thanks for your reply.

    Yes, I think the key point is “how to edit/modify the phone’s routing table.” Is there any way by which we (phone users) are able to edit/modify the routing table ?

    I want to access another phone’s ip,, so I tried to add a route with DOS command “route” as follows, but it showed “The system cannot find the file specified.”

    C:\Windows\system32>route add mask metric 30 if
    The route addition failed: The system cannot find the file specified.
    <<route PRINT
    Interface List
      6...5e b5 7d 3b e0 ba ......Microsoft Hosted Network Virtual Adapter
      5...1e b5 7d 3b e0 ba ......Microsoft Wi-Fi Direct Virtual Adapter b5 7d 3b e0 ba ......Qualcomm Atheros AR956x Wireless Network Adapter
      3...f0 76 1c 38 2a 45 ......Realtek PCIe GBE Family Controller
     18...08 00 27 00 30 2d ......VirtualBox Host-Only Ethernet Adapter
      1...........................Software Loopback Interface 1
    IPv4 Route Table
    Active Routes:
    Network       Netmask     Gateway      Interface               Metric
    Destination    25               On-link            306  On-link           306  On-link              306       On-link    281    On-link  281    On-link  281           On-link       276         On-link       276    On-link      276         On-link               306         On-link        276         On-link    281  On-link            306  On-link      276  On-link  281
    Persistent Routes:
    IPv6 Route Table
    Active Routes:
     If Metric Network Destination      Gateway
      1    306 ::1/128                  On-link
     18    276 fe80::/64                On-link
      4    281 fe80::/64                On-link
      4    281 fe80::9196:9e5f:75c2:6b76/128
     18    276 fe80::e4b9:e415:fded:afb6/128
      1    306 ff00::/8                 On-link
     18    276 ff00::/8                 On-link
      4    281 ff00::/8                 On-link
    Persistent Routes:

    Thanks and Best regards,

  9. If a pc1 is connected to both internet and local server. How can i access local server from pc2 (remote pc not connected to local network) . When pc1 and pc2 are connected via internet.

  10. Sir,
    I want to run website on locally connected PCs(LAN). I am using xampp and WordPress and try to access from other locally connected PCs but not able to open the site.but in server side it’s working. Here all PCs have a proxy settings.

    Thanks with regard

  11. Hello,

    I have installed wampserver 3.1.7 with wordpress 5.0.3 on window 7.

    Default wampserver 3.1.7 installation
    For wordpress 5.0.3 below link.

    I have created single website which need to access by LAN connected computers but not succeed.

    http://ip address/mysite – url

    host localhost mysite
    ::1 localhost
    ::1 mysite

    Can you please suggest steps or m I doing something wrong while installation.

    Thanks in advance!!

    1. the host file does mean that an IP address corresponds to a hostname and the other way around. So, from another computer on the LAN, from any computer, the host file to connect to the “LAN web server” must contain the web server IP address and the hostname. eg. so any computer on local network can connect to

Leave a Reply to admin Cancel reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>