'How do I connect to this localhost from another computer on the same network?

I'm currently working on a project and I would like to test it out on two laptops at home where one laptop connects to the localhost on the other. I am using XAMPP. How do I do this?



Solution 1:[1]

For testing on both laptops on the same wireless and across the internet you could use a service like http://localhost.run/ or https://ngrok.com/

Solution 2:[2]

On Mac OS X:

  1. In terminal, run ifconfig to get the internal IP of your machine on its current network. It may be something like 192.168.1.140 or 10.0.1.174.

  2. Start a server. For example, node server.js may start a server on some port.

  3. On your phone, visit the IP address (e.g. 192.168.1.140:3000) and be sure to specify the port.

Solution 3:[3]

Provided both machines are in the same workgroup, open cmd.exe on the machine you want to connect to, type ipconfig, and note the IP at the IPv4 Address line.

Then, on the machine you want to connect with, use

http://{the IP of the target machine}:{port number}

E.g http://192.168.0.1:80 if your site runs on port 80.

That should do it.

Solution 4:[4]

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 5:[5]

it may be that your firewalls are preventing you from accessing the localhost's webserver.
Put the IP addresses of both of your computers' internet security antivirus network security as safe IP addresses if required.
How to find the IP address of your windows PC: Start > (Run) type in: cmd (Enter)
(This opens the black box command prompt)
type in ipconfig (Enter)
Let's say your Apache or IIS webserver is installed on your PC: 192.168.0.3
and you want to access your webserver with your laptop. (laptop's IP is 192.168.0.5)
On your PC you type in: http://localhost/ inside your Firefox or Internet Eplorer browser to access your data on your webserver.
On your laptop you type in http://192.168.0.3/ to access your webserver on your PC.

For all these things to work you need have installed a webserver correctly (e.g. IIS, Apache, XAMP, WAMP etc).

If it does not work, try to ping your PC from your laptop:
Open up command propmt on your laptop: Start > cmd (Enter)
ping 192.168.1.3 (Enter)
If the pinging fails, then firewalls are blocking your connection or your network cabling is faulty. Restart your modem or network switch and your machines.
Close programs such as chat programs that are using your ports.
You can also try a diffrent port number: http:192.168.0.3:80 or http:192.168.0.3:81 or any random number at the end

Solution 6:[6]

This is a side note if one still can't access localhost from another devices after following through the step above. This might be due to the apache ports.conf has been configured to serve locally (127.0.0.1) and not to outside.

check the following, (for ubuntu apache2)

  $ cat /etc/apache2/ports.conf

if the following is set,

NameVirtualHost *:80  
Listen 127.0.0.1:80  

then change it back to default value

NameVirtualHost *:80  
Listen 80  

Solution 7:[7]

If you are on Windows, use ipconfig to get the local IPv4 address, and then specify that under your Apache configuration file: httpd.conf, like:

Listen: 10.20.30.40:80

Restart your Apache server and test it from other computer on the network.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 tommyvn
Solution 2
Solution 3 Tim Skov Jacobsen
Solution 4 Thiago C. S Ventura
Solution 5
Solution 6 ken
Solution 7 shasi kanth