How to access localhost from another computer connected to the same network?

Last Updated on January 5, 2024 by Amarjit Singh

Sometimes there occurs a situation. where you have to show your website which is hosted on your computer to your boss or to any of your colleagues who are not sitting beside you. But he is connected to the same network that your computer is connected to.

In this case, you can show your website to your boss or colleague. All you have to do is just allow traffic for the port that your web server is listening on.

Note: If you want to access your localhost on a computer that is not connected to the same LAN. Then you should read this article.

Here are the steps to make localhost accessible from any computer on the same local network.

Make localhost accessible from another computer on Windows.

  1. Go to Windows Firewall settings and click on advanced settings.

Advanced Settings in Windows Firewall

2. In the Inbound rules, click on “New Rule” option and a wizard window will pop up.

New Inbound Rule option in windows firewall settings

3. In the wizard there are five steps. In the first step, you have to select the type of rule. Since we are to allow traffic for a specific port. Therefore select the port option.

First Step of new Inbound Rule wizard

4. Now choose “Specific local ports” option and enter the port number that your web server is listening on.

If you don’t know on which port your web server is listening on then it is the number that you specify after ” : ” symbol in URL bar of your web browser while opening localhost on your computer. Eg: If you type “localhost:8000” or “127.0.0.1:8000” to access localhost on your computer then your web server is listening on port number “8000”. But If you don’t specify any number, that is you only type “localhost” or “127.0.0.1” then your browser implicitly enters default port. which is port number “80”. That means your web server is listening on port number “80”.

Second step of new Inbound Rule wizard

5. Now you have to choose an action. choose “Allow the connection”.

Third step of new Inbound Rule wizard

6. Now specify when this rule should apply. choose all of the options.

Fourth step of new Inbound Rule wizard

7. Now give a name for this rule. You can also specify a description for this rule which is not mandatory.

Fifth step of new Inbound Rule wizard

8. Finally click on the finish button to save the new rule.

now just go ahead and type the local IP address of your computer in the web browser of another computer that is connected to the same local network. To find the local IP address of your use ipconfig command.

If It doesn’t work then you have to configure your web server to listen on local IP address or all available IP addresses for your computer.

Following are the steps to do it for the XAMP server:

  1. Locate the Apache Configuration File:
    • The Apache server, which is part of XAMPP, has a configuration file named httpd.conf.
    • This file is usually located in the apache\conf directory within your XAMPP installation. The default path is often C:\xampp\apache\conf\httpd.conf on Windows.
  2. Edit the httpd.conf File:
    • Open the httpd.conf file in a text editor such as Notepad or any other editor of your choice.
    • To allow Apache to listen on all available IPs, you need to find the line that starts with Listen. This line might look like Listen 80, Listen 127.0.0.1:80, or something similar.
  3. Change the Listen Directive:
    • To make Apache listen on all available IP addresses, change the Listen directive to Listen 80. This tells Apache to listen on port 80 for all available IP addresses.
    • If it’s set to something like Listen 127.0.0.1:80, it is currently configured to listen only on the local loopback interface (localhost) on port 80. Change it to 0.0.0.0:80. Don’t change the port number only change the IP. Otherwise, you will have to do all the steps from the start of this article for the new port number that you have just entered.
  4. Save and Close the File:
    • After making the change, save the httpd.conf file.
  5. Restart Apache:
    • For the changes to take effect, you need to restart the Apache service.
    • You can do this from the XAMPP Control Panel by stopping and then starting the Apache module.

Make localhost accessible from another computer on Ubuntu.

In Ubuntu, the requests for port 80 are already allowed. Therefore you don’t have to mess up with firewall settings. Just type your Local IP address in a web browser on another computer.

To find the local IP address of your computer type ifconfig in terminal.

14 comments on “How to access localhost from another computer connected to the same network?

    1. Amarjit Singh Post author

      1. Mobile phones can also access the localhost if it is connected to the same network as that of the computer.
      2. It doesn’t require internet connection

      Reply
  1. David

    I followed your guide, it worked to the point of being able to access my WAMPserver www content, so long as the content was just static html pages. But I cannot get my wordpress site to show up on remote networked machines. Firewall shut down, root directory and not vhost, with wampserver set to “online” mode. Have you got any ideas what my problem might be, please?

    Reply
    1. Amarjit Singh Post author

      Hi
      yeah, I understood your problem. But not the last part of it “firewall shutdown, root directory and not vhost etc”. From the part I understood is that your www content is running on a different port than the port on which WordPress is running.

      Reply
  2. Spiritlight

    Hi,
    My localhost is running the 81 port number (localhost:81). I tried to type my local IP address (10.5.20.19) in web browser of other computer which is connected to same local network. Unfortunately, it redirects to 10.5.20.19/dashboard/ which is a website of XAMPP. I’d like to know whats wrong ?

    Reply
    1. Amarjit Singh Post author

      Hi
      If you access your website on your computer by using localhost:81 then you will need to put “:81” after your computer IP on the other computer. If you just put an IP on another computer then it will use port 80 by default but on port 80 your XAMP dashboard is running. Also in the windows firewall rule, you need to put port 81.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *