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.
- Go to Windows Firewall settings and click on advanced settings.
2. In the Inbound rules, click on “New Rule” option and a wizard window will pop up.
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.
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”.
5. Now you have to choose an action. choose “Allow the connection”.
6. Now specify when this rule should apply. choose all of the options.
7. Now give a name for this rule. You can also specify a description for this rule which is not mandatory.
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:
- 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 oftenC:\xampp\apache\conf\httpd.conf
on Windows.
- The Apache server, which is part of XAMPP, has a configuration file named
- 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 likeListen 80
,Listen 127.0.0.1:80
, or something similar.
- Open the
- Change the Listen Directive:
- To make Apache listen on all available IP addresses, change the
Listen
directive toListen 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.
- To make Apache listen on all available IP addresses, change the
- Save and Close the File:
- After making the change, save the
httpd.conf
file.
- After making the change, save the
- 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.
thank you very much.
will it be connected if the device is shut down?
no, it won’t work if the system is shut down.
Thanks it works well
This works perfectly! Thanks so much 🙂
You’re Welcome 🙂
1.What about phones connected via hotspot with the computer
2. Does it requires internet connection?
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
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?
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.
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 ?
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.
How to check port of local host…its not working
What URL do you use to access your localhost?