Accessing localhost (xampp) from another computer over LAN network - how to?

724,690

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

  1. Go to Your XAMPP Control panel
  2. Click on apache > config > Apache (httpd.conf) enter image description here
  3. Search for Listen 80 and replace with Listen 8080
  4. After that check your local ip using ipconfig command (cmd console)
  5. Search for ServerName localhost:80 and replace with your local ip:8080 (ex.192.168.1.156:8080)
  6. After that open apache > config > Apache (httpd-xampp.conf) enter image description here
  7. Search for

       <Directory "C:/xampp/phpMyAdmin">
           AllowOverride AuthConfig
           **Require local**   Replace with   **Require all granted**
           ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
       </Directory>```
    
    
  8. Go to xampp > config > click on service and port setting and change apache port 8080

  9. restart xampp
  10. 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)

  1. Get the internal IP or Static IP of the server (Ex: 192.168.1.193)
  2. Open XAMPP>apache>conf>httpd.conf file in notepad
  3. Search for Listen 80
  4. Above line would read like- #Listen 0.0.0.0:80 / 12.34.56.78:80
  5. Change the IP address and replace it with the static IP
  6. Save the httpd.conf file ensuring that the server is pointed to #Listen 192.168.1.193:80
  7. 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.

Share:
724,690

Related videos on Youtube

bcosynot
Author by

bcosynot

Updated on February 10, 2022

Comments

  • bcosynot
    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
      Martin Thoma almost 10 years
      People finding this question might be interested in How do I connect to this localhost from another computer on the same network?.
    • csandreas1
      csandreas1 over 7 years
      Here 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
      vicky about 5 years
      I 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
    bcosynot about 13 years
    httpd.conf: Listen 80 if I need to make a change to that, what would you recommend?
  • BugFinder
    BugFinder about 13 years
    That 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
    bcosynot about 13 years
    protocol:tcp, local address:0.0.0.0:80, foreign address:desktoppcname, state:listening
  • BugFinder
    BugFinder about 13 years
    There 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
    bcosynot about 13 years
    except I get a "this website is temporarily down or moved to another location" message when I try to do that
  • BugFinder
    BugFinder about 13 years
    if 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
    bcosynot about 13 years
    bingo. 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
    BugFinder about 13 years
    Ok, 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
    bcosynot about 13 years
    its a windows vista pc. running windows firewall.
  • bcosynot
    bcosynot about 13 years
    aha. got it working. that was the main issue. allowed port 80 on my subnet. thanks a lot for your help!
  • BugFinder
    BugFinder about 13 years
    I 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
    lowtechsun over 8 years
    This 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
    lowtechsun over 8 years
    To 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
    shasi kanth about 8 years
    I 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
    Claudia almost 8 years
    First 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
    dkjain over 7 years
    Hi, what about a range of IP addresses for e.g. 192.168.1-100. How to set that?
  • asd
    asd over 7 years
    <Files ".ht*"> Require local #Require all denied </Files>
  • kayess
    kayess over 7 years
    Welcome 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
    jewelhuq over 6 years
    Thank you. Working fine.
  • vivanov
    vivanov over 6 years
    For XAMPP Version 7 the "Require local" is located in the file apache/conf/extra/httpd-vhosts.conf
  • alejnavab
    alejnavab over 5 years
    To add the Windows Firewall exception, you can visit this to learn how: tomshardware.com/news/…
  • Alejandro Maliachi Quintana
    Alejandro Maliachi Quintana over 5 years
    if instead of all graned... jsut an static IP. how it would be?
  • Femn Dharamshi
    Femn Dharamshi over 5 years
    I 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
    BugFinder over 5 years
    Well, 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
    Jibin over 4 years
    Is 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
    BugFinder over 4 years
    If dns has it registered as that name yes
  • MH Fuad
    MH Fuad over 4 years
    not working. in my pc it's work fine but not working from another pc .
  • Jon Vote
    Jon Vote over 4 years
    This doesn't work for me. I'm getting a certificate error: server certificate does NOT include an ID which matches the server name
  • Ingus
    Ingus over 3 years
    Hi @Rahul Shewale this works for IP but how to make it work for domain/subdomain? example portal.localhost?
  • greendino
    greendino over 3 years
    doesn't work for me. sorry. also this is a duplicate answer
  • greendino
    greendino over 3 years
    isn't this the question itself?
  • Kishita Variya
    Kishita Variya almost 3 years
    Will this make my PC more vulnerable to attacks (outside LAN) ?
  • Admin
    Admin over 2 years
    Please add further details to expand on your answer, such as working code or documentation citations.
  • LW001
    LW001 over 2 years
    There's no real reason I could see why this would not work on Windows 10 Home, could you elaborate on that?
  • Valkay
    Valkay over 2 years
    @shasikanth you should add as an answer. Worked well for me.