Accessing localhost (xampp) from another computer over LAN network - how to?
Solution 1
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
Solution 2
it's very easy
- Go to Your XAMPP Control panel
- Click on apache > config > Apache (httpd.conf)
- Search for Listen 80 and replace with Listen 8080
- After that check your local ip using ipconfig command (cmd console)
- Search for ServerName localhost:80 and replace with your local ip:8080 (ex.192.168.1.156:8080)
- After that open apache > config > Apache (httpd-xampp.conf)
-
Search for
<Directory "C:/xampp/phpMyAdmin"> AllowOverride AuthConfig **Require local** Replace with **Require all granted** ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var </Directory>```
Go to xampp > config > click on service and port setting and change apache port 8080
- restart xampp
- then hit your IP:8080 (ex.192.168.1.156:8080) from another computer
Solution 3
Thanks for a detailed explanation.
Just to Elaborate, in Windows, Go to Control Panel -> Firewall, in exceptions "add http and port 80". Then in Services check mark "http (web server port 80)" and "https (web server port 443)" ONLY if you need https to work also. Ok, OK, Close
Then go to any computer on network and type http://computer-name (where you change the firewall and has the xampp running on it) in your web browser and happy days :)
Solution 4
These are the steps to follow when you want your PHP application to be installed on a LAN server (not on web)
- Get the internal IP or Static IP of the server (Ex: 192.168.1.193)
- Open XAMPP>apache>conf>httpd.conf file in notepad
- Search for Listen 80
- Above line would read like- #Listen 0.0.0.0:80 / 12.34.56.78:80
- Change the IP address and replace it with the static IP
- Save the httpd.conf file ensuring that the server is pointed to #Listen 192.168.1.193:80
- In the application root config.php (db connection) replace localhost with IP address of the server
Note: If firewall is installed, ensure that you add the http port 80 and 8080 to exceptions and allow to listen. Go to Control Panel>Windows Firewall>Allow a program to communicate through windows firewall>Add another program Name: http Port: 80 Add one more as http - 8080
If IIS (Microsoft .Net Application Internet Information Server) is installed with any Microsoft .Net application already on server, then it would have already occupied 80 port. In that case change the #Listen 192.168.1.193:80 to #Listen 192.168.1.193:8080
Hope this helps! :)
Solution 5
Sometimes your firewall can be the problem. Make sure you've disabled your antivirus firewall monitoring. It worked for me.
Related videos on Youtube
bcosynot
Updated on February 10, 2022Comments
-
bcosynot about 2 years
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.1.2).
On my desktop I can access localhost through the normal http://localhost. Apache is running on port 80 as usual.
What do I have to do to achieve this? There is documentation on the net but they either don't work or are too fragmented and confusing to understand.
I think I have to make changes to my apache's httpd.conf file and the hosts file. Any ideas as to what changes to make?
-
Martin Thoma almost 10 yearsPeople finding this question might be interested in How do I connect to this localhost from another computer on the same network?.
-
csandreas1 over 7 yearsHere is what i did and worked for me on windows 10: go to cmd and type ipconfig, then find your ipv4 address and rename your website url to that ip eg: 192.168.0.2/example. Then search windows for "Allow an app through windows firewall" click on it then click change settings and make sure the http apache server is ticked. Hope it helps
-
vicky about 5 yearsI am having a site named app.sitename.com. Now i can access site in another pc in same network using IP address. How to access with subdomian. app.ipaddress.com is not working. What i to do to add subdomain in remote pc?
-
-
bcosynot about 13 yearshttpd.conf: Listen 80 if I need to make a change to that, what would you recommend?
-
BugFinder about 13 yearsThat just says listen on port 80, chances are its already listening. netstat -a , look for items on port 80, it will tell you which IP(s) its listening on
-
bcosynot about 13 yearsprotocol:tcp, local address:0.0.0.0:80, foreign address:desktoppcname, state:listening
-
BugFinder about 13 yearsThere you go, that means its listening for any request on port 80, not just localhost, so, if your PC was called vr3609, then http to it should take you to your website.
-
bcosynot about 13 yearsexcept I get a "this website is temporarily down or moved to another location" message when I try to do that
-
BugFinder about 13 yearsif you http to the ip address of your server from the server, does it work? if so, its suggesting theres a firewall on the server blocking other machines getting to it.
-
bcosynot about 13 yearsbingo. when i use 192.168.1.56 on desktop pc, i am able to see the site. so I am guessing I have a firewall problem. how do I fix this?
-
BugFinder about 13 yearsOk, 192.168.1.56, thats the one with the website on right? You need to look at the config of it. What OS does it run? What firewall software is on it will vary with that. You need to find out what firewall software is on it, and then work out how to add port 80 to it to let other machines in. If its windows, chances are its part of your antivirus software, or, could even be the microsoft one. If its linux chances are its ipchains but, its a whole new area of question.
-
bcosynot about 13 yearsits a windows vista pc. running windows firewall.
-
bcosynot about 13 yearsaha. got it working. that was the main issue. allowed port 80 on my subnet. thanks a lot for your help!
-
BugFinder about 13 yearsI dont have vista, but on windows 7 under control panel, theres a windows firewall option, under there advanced you could go add port 80.
-
lowtechsun over 8 yearsThis solved it for me. Great stuff! I always had deleted the
#
in front of the local IP address and it was not working, when I included the comment hash#
it worked out of the box without restarting the guest VM, just the XAMPP Apache service and bang it is there. Nice one. Now how do I get it to link to my assigned VirutalHosts on the Host machine? -
lowtechsun over 8 yearsTo access the assigned VirtualHosts on the Host machine from the guest I simply had to enter the Host's IP and the name of the VirtualHost server(s) in the Guest's HOSTS file. Done. Anyone know how to pick up traffic from the Guest's browser to the Hosts Apache server with Fiddler. Work on the Host but not getting traffic from guest.
-
shasi kanth about 8 yearsI went to Control Panel > Windows Firewall > Allow an app through Windows Firewall > Allow another app > Browse to: XAMPP/apache/bin/httpd.exe and allowed it. It is working now!
-
Claudia almost 8 yearsFirst of all, this post is 5 years old, so this answer probably won't be helpful to the OP. Second, you can use Markdown to improve the formatting of your answer to make it more readable and easier to follow. Trust me in that it's a nice thing to know. :-)
-
dkjain over 7 yearsHi, what about a range of IP addresses for e.g. 192.168.1-100. How to set that?
-
asd over 7 years<Files ".ht*"> Require local #Require all denied </Files>
-
kayess over 7 yearsWelcome to Stack Overflow! While this code snippet may solve the question, including an explanation really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. Please also try not to crowd your code with explanatory comments, this reduces the readability of both the code and the explanations!
-
jewelhuq over 6 yearsThank you. Working fine.
-
vivanov over 6 yearsFor XAMPP Version 7 the "Require local" is located in the file apache/conf/extra/httpd-vhosts.conf
-
alejnavab over 5 yearsTo add the Windows Firewall exception, you can visit this to learn how: tomshardware.com/news/…
-
Alejandro Maliachi Quintana over 5 yearsif instead of all graned... jsut an static IP. how it would be?
-
Femn Dharamshi over 5 yearsI have a MacOs, i installed xampp and started Apache and Mysql, imagine my ip is 192.168.64.2 (this is what xampp shows) then when i enter this ip on my mobile browser it wont open. What could be the problem ? ifconfig shows my ip as 192.168.0.102
-
BugFinder over 5 yearsWell, you likely have 2 ip addresses, depending on so many things. Look at netstat and see what ip and port it is listening on.
-
Jibin over 4 yearsIs it possible to access 192.168.1.5/project by using the hostname of the desktop with up 192.168.1.56 as pc_test/project if the host name is pc_test.
-
BugFinder over 4 yearsIf dns has it registered as that name yes
-
MH Fuad over 4 yearsnot working. in my pc it's work fine but not working from another pc .
-
Jon Vote over 4 yearsThis doesn't work for me. I'm getting a certificate error: server certificate does NOT include an ID which matches the server name
-
Ingus over 3 yearsHi @Rahul Shewale this works for IP but how to make it work for domain/subdomain? example
portal.localhost
? -
greendino over 3 yearsdoesn't work for me. sorry. also this is a duplicate answer
-
greendino over 3 yearsisn't this the question itself?
-
Kishita Variya almost 3 yearsWill this make my PC more vulnerable to attacks (outside LAN) ?
-
Admin over 2 yearsPlease add further details to expand on your answer, such as working code or documentation citations.
-
LW001 over 2 yearsThere's no real reason I could see why this would not work on Windows 10 Home, could you elaborate on that?
-
Valkay over 2 years@shasikanth you should add as an answer. Worked well for me.