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

ApacheXamppLocalhostRemote Debugginghttpd.conf

Apache Problem Overview


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?

Apache Solutions


Solution 1 - Apache

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 - Apache

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 - Apache

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 - Apache

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 - Apache

Sometimes your firewall can be the problem. Make sure you've disabled your antivirus firewall monitoring. It worked for me.

Solution 6 - Apache

This should be all you need for a basic setup

This kind of configuration doesn't break phpMyAdmin on localhost

A static IP is recommended on the device running the server

This example uses the 192.168.1.x IP. Your network configuration might use a different IP

In the httpd.conf in Apache you should have:

# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to 
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80

I would leave blank the name so it gets the defaults:

# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#

Allow the guest machines and yourself. As a security caution, you might avoid Allow from all but instead use specific guest IP for example Allow from 192.168.1.xxx where xxx is the guest machine IP. In this case you might need to consider static IPs on guest machines also

# Controls who can get stuff from this server.
#
#    Require all granted
#   onlineoffline tag - don't remove
     Order Deny,Allow
#     Deny from all
     Allow from all 
     Allow from 127.0.0.1
     Allow from ::1
     Allow from localhost
     Allow from 192.168.1.*YOURguestIP*
     Allow from 192.168.1.*YOURselfIP*
</Directory>

Restart all services and Put Online from the tray icon

Solution 7 - Apache

Go to xampp-control in the Taskbar

xampp-control -> Apache --> Config --> httpd.conf

Notepad will open with the config file

Search for

> Listen 80

One line above it, there will be something like this: 12.34.56:80

Change it

12.34.56:80 --> <your_ip_address eg:192.168.1.5>:80

Restart the apache service and check it, Hopefully it should work...

Solution 8 - Apache

If you are using XAMPP 1.8.3 Navigate to file httpd-xampp.conf and search for " # # New XAMPP security concept # server-status | server-info))">

     Require local
     ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
     </LocationMatch>

"

Cut this code and save it somewhere for later use i.e restoring this feature( remember removing this code makes your computer vulnerable). Save changes on httpd-xampp.conf, restart services on XAMPP and that's it.

Solution 9 - Apache

Access localhost from Remote Device

Prerequisite: Your website is currently on http://localhost:8081/ with a tool like live-server

a) Publish on Same Network

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.

b) Publish on Any Network (easier)
  1. 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
    

    https://i.stack.imgur.com/rkYfE.png" width="450" />

  2. 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
    

    https://i.stack.imgur.com/lAQ9N.png" width="450" />


Access Remote Device from Local Dev Tools

To connect your browser dev tools with a connected device, follow the instructions at Get Started with Remote Debugging Android Devices

  1. On your phone, enable Developer Options & USB Debugging

  2. Plug your phone into your computer via USB and set the protocol (not File / Media Transfer)

  3. Open Dev Tools > More Tools > Remote Debugging (try here if Device Not Detected)

    https://i.stack.imgur.com/pJTw5.png" width="450" />

  4. Find your site and Click Inspect which will open up a new inspector window

<img src="https://i.stack.imgur.com/EtrqL.png" width="450" />

Further Reading:

Solution 10 - Apache

This tool saved me a lot, since I have no Admin permission on my machine and already had nodejs installed. For some reason the configuration on my network does not give me access to other machines just pointing the IP on the browser.

# Using a local.dev vhost
$ browser-sync start --proxy

# Using a local.dev vhost with PORT
$ browser-sync start --proxy local.dev:8001

# Using a localhost address
$ browser-sync start --proxy localhost:8001

# Using a localhost address in a sub-dir
$ browser-sync start --proxy localhost:8080/site1

http://www.browsersync.io/docs/command-line/

Solution 11 - Apache

If someone is still finding it hard, this simple thing worked for me:

  1. 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
  • In my case there were two "Apache HTTP Server" entries, so I checked both the check-boxes for both entries.
  1. 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.

Solution 12 - Apache

After ensuring you've got the appache configs set up as described in the other answers on this page, you may need to also open TCP ports through your firewall as described here:

https://superuser.com/questions/569227/xampp-is-not-accessible-from-other-computer-through-lan-when-firewall-is-enable

Solution 13 - Apache

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

Solution 14 - Apache

Here is what i did and worked for me on windows 10:

  1. Hit windows + r and type cmd . In the command prompt type ipconfig
  2. find your ipv4 address and rename your website url to that ip eg: http://192.168.0.2/example.
  3. Now make sure your firewall has access to Apache HTTP Server. Search windows for "Allow an app through windows firewall" click on it then on the top right click change settings and make sure the Apache HTTP Server has one tick on the left and one on the private or public. Hope it helps

Now you can access the website from other PCs in the lan

Solution 15 - Apache

Just try:

http://ipaddressofpcwhichhasdatabase:portnumber(80 by default)/filename.extension

Solution 16 - Apache

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

Solution 17 - Apache

<Files ".ht*">
 Require all denied
</Files>

 replace to

<Files ".ht*">
 Require local
</Files>

Solution 18 - Apache

First Go To Network and Sharing center of your windows machine.and Just follow some steps to get your IPv4 address. Just See The Image Illustration

Put the IPv4 adress on another computer browser. example,http//192.168.0.102

Note

  • Turn Of Your Windows Firewall (if does not work,otherwise its optional)

Solution 19 - Apache

Replace Require Local with Require all granted in xampp\apache\conf\extra\httpd-xampp.conf file.

Solution 20 - Apache

I was having this issue. I was using XAMPP in a virtual machine which was having network setting as "NAT". I changed it to "Bridged" and the problem got solved.

Solution 21 - Apache

Host in local IP,

Open CMD : ipconfig

Wireless LAN adapter Wi-Fi: IPv4 Address. . . . . . . . . . . : xx.xxx.xx.xxx

Solution 22 - Apache

I noticed that windows 10 home edition does not support hosting website.

windows 10 professional does support hosting website, so it works once add the windows machines ip address to httpd.conf file after listen 80, the ip address for the local hosting windows machine can be found by ipconfig in cmd windows.

Listen 80

Listen 192.168.0.197:80

Solution 23 - Apache

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.

Solution 24 - Apache

I am Fully agree With BugFinder.

In simple Words, just put ip address 192.168.1.56 in your browser running on 192.168.1.2!

if it does not work then there are following possible reasons for that :

  1. Network Connectivity Issue :

    • First of all Check your network Connectivity using ping 192.168.1.56 command in command prompt/terminal on 192.168.1.2 computer.
  2. Firewall Problem : Your windows firewall setting do not have allowing rule for XAMPP(apache). (Most probable problem)

    • (solution) go to advanced firewall settings and add inbound and outbound rules for Apache executable file.
  3. Apache Configuration problem. : Your apache is configured to listen only local requests.

    • (Solution) you can it by opening httpd.conf file and replace Listen 127.0.0.1:80 to Listen 80 or *Listen :80
  4. Port Conflict with other Servers(IIS etc.)

    • (Solution) Turn off apache server and then open local host in browser. if any response is obtained then turnoff that server then start Apache.

if all above does not work then probably there is some configuration problem on your apache server.try to find it out otherwise just reinstall it and transfer all php files(htdocs) to new installation of XAMPP/WAMP.

Solution 25 - Apache

To Run Nodejs Server over Network

const port = process.env.PORT || 3000; 
const server = http.createServer( 
server.listen(port, '0.0.0.0', ()  => console.log(`Server started on port ${port}`)
));

run http://yournetworkipaddress:3000 to access your application over local area network (LAN)

Steps to find your network ip.

MacOS

  1. Go to System Preferences > Network
  2. Check network IP address under the connected.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionbcosynotView Question on Stackoverflow
Solution 1 - ApacheBugFinderView Answer on Stackoverflow
Solution 2 - ApacheRahul ShewaleView Answer on Stackoverflow
Solution 3 - ApacheRajaView Answer on Stackoverflow
Solution 4 - ApacheShreedhar BhatView Answer on Stackoverflow
Solution 5 - ApacheMateo JovaniView Answer on Stackoverflow
Solution 6 - ApacheRazamanView Answer on Stackoverflow
Solution 7 - ApacheJoishView Answer on Stackoverflow
Solution 8 - ApacheOnsareTMView Answer on Stackoverflow
Solution 9 - ApacheKyleMitView Answer on Stackoverflow
Solution 10 - ApacheThiago C. S VenturaView Answer on Stackoverflow
Solution 11 - ApachenareshsrView Answer on Stackoverflow
Solution 12 - ApachebobView Answer on Stackoverflow
Solution 13 - ApacheKrishna MView Answer on Stackoverflow
Solution 14 - Apachecsandreas1View Answer on Stackoverflow
Solution 15 - ApacheChinthan NarayanView Answer on Stackoverflow
Solution 16 - ApacheCarl James OmandamView Answer on Stackoverflow
Solution 17 - ApacheasdView Answer on Stackoverflow
Solution 18 - ApacheThat's EnamView Answer on Stackoverflow
Solution 19 - ApacheSumitView Answer on Stackoverflow
Solution 20 - ApacheVidhyadhar DharmadhikariView Answer on Stackoverflow
Solution 21 - ApacheVineesh TPView Answer on Stackoverflow
Solution 22 - ApacheJoshView Answer on Stackoverflow
Solution 23 - ApacheMark HartmanView Answer on Stackoverflow
Solution 24 - ApacheSmit PatelView Answer on Stackoverflow
Solution 25 - ApacheSumit KasanaView Answer on Stackoverflow