I have just set up a wi-fi network at home. I have all my files on my desktop computer (192.168.1.56) and want to access localhost over there from another computer (192.168.
Prerequisite: Your website is currently on http://localhost:8081/
with a tool like live-server
Within the same network, you can access your machine with your current ip address or hostname. You can find the ip address running ipconfig | grep IPv4
or the hostname by sending a ping -a
to that ip.
http://192.128.1.18:80/
http://hostname:80/
Note: For best results, use port 80, connect on a private network, and check your firewall settings.
Opt 1 - You can use ngrok to provide port forwarding over ngrok's public facing ports
Download ngrok and run the following command:
$ ./ngrok http 8081
Opt 2 - You can use localhost.run to create a ssh tunnel with the following command:
ssh -R 80:localhost:8081 kylemit@ssh.localhost.run
To connect your browser dev tools with a connected device, follow the instructions at Get Started with Remote Debugging Android Devices
Open Dev Tools > More Tools > Remote Debugging (try here if Device Not Detected)
Find your site and Click Inspect which will open up a new inspector window
First you go to Command Prompt and type
Notepad C:/windows/system32/drivers/etc/hosts
then add your ip adress below then the url of your site.
Second you go to Command Prompt and type
notepad c:/xampp/bin/apache/apache2.4.18/conf/extra/httpd-vhosts.conf
then add this below
documentroot "Directory of your site"
Allow from all
Require all granted
So I was trying to solve a similar problem with connecting to a totally different server on my own LAN so that when power is interrupted and then restored that my server comes back online and other systems can still have connectivity with automation. However, my problem was DHCP giving my server a diff IP on occasion. This thread answered my problem with the NAMESERVER that windows have natively. I was connecting directly to my servers IP add http://192.168.1.5 through a batch file to initialize the connection but when power problems happen it would not connect. I changed the .bat file to point at http://DESKTOP-actualnamewhereserver:port and done. Problem solved. IF I don't change my computers names then when DHCP hands DESKTOP-actualnamewhereserver a new IP address it will still identify as its own name on the LAN and therefore be able to accept the connection regardless of it's IP Address. Simply give the other people on your wireless LAN the name of your pc hosting the Apache server and lets say its name is DESKTOP-DOUGHFACTORYHUT they will type http://DOUGHFACTORYHUT:80 or whatever port number your apache config is set to host at like LOCALHOST:80 which essentially are the same thing attached to your local Dynamic IP address assigned by DHCP or STATIC IP you have set to the server.
Localhost is just a name given for the loopback, eg its like referring to yourself as "me" ..
To view it from other computers, chances are you need only do http://192.168.1.56 or http://myPcsName if that doesnt work, there is a chance that there is a firewall running on your computer, or the httpd.conf is only listening on 127.0.0.1
If you are connected to Wi-Fi network, then it is much simpler. Just find the Ip in which you have connected to the Wi-Fi. Eg:
your-ip is "10.10.55.67".
Then start the xampp server in your machine.
Then in anyother computer connected to the same Wi-Fi n/w, type
http://your-ip
Eg:http://10.10.55.67
If someone is still finding it hard, this simple thing worked for me:
On you main system let's say Hosting PC... Go to Control Panel > Windows Defender Firewall > Allow an app or feature through Windows Defender Firewall > Change settings > Find "Apache HTTP Server" > Check both the check-boxes (under Private & Public). See Screenshot
On any another system connected over a same network... Open browser > type: your hosting pc's IP adress followed by your project name in the url bar. Example: 192.168.72.111/example.com/
Hope it helps! Thanks.