Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect to localhost from another computer

I make database program and use localhost as host. I want my friend to test my program but I don't know how to connect from another computer.

PS. I use windows 7 and MySql.

like image 562
aratn0n Avatar asked Feb 01 '13 06:02

aratn0n


People also ask

Can I access my localhost from another computer?

We first need to know the IP address on the computer that hosts the website (the one we've been working on since the very beginning). In the terminal, on MAC and LINUX type ifconfig |grep inet , on WINDOWS type ipconfig . Let's assume the IP address of this computer is 192.168.

How do I connect to a localhost remotely?

Open any browser you like and type http://localhost:9999 and it will work like a charm.

How can I access localhost from everywhere?

You are accesing localhost , meaning you have a web server running on your machine. To access it from Internet, you need to assign a public IP address to your machine. Then you can access http://<public_ip>:<port>/ . Port number is normally 80.


1 Answers

localhost is just an alias for the loopback address 127.0.0.1, which means this computer.

If you want to communicate with that computer from somewhere else, you'll need to use its real IP address.

For example, see the following "diagram" showing where connectons will go depending on the IP address used:

    +-----------+ 10.1.1.8 +-----------+
    | MyPC      | <------- | YourPC    |
    |           |          |           |
    | 10.1.1.8  | -------> | 10.1.1.9  |
    +-----------+ 10.1.1.9 +-----------+
      |       ^              |       ^
      |       |              |       |
    127.0.0.1-+            127.0.0.1-+

With Windows, you should be able to get your IP address with ipconfig (ifconfig under most UNIX-type systems) and just plug that into your connection parameters where you currently have localhost.

Keep in mind that you may still need to grant power to the remote IP address to connect, such as with (assuming you're trying to connect from 10.1.1.8):

GRANT ALL PRIVILEGES ON *.* TO 'mysql'@'10.1.1.8' IDENTIFIED BY 'super-sekrit'
like image 74
paxdiablo Avatar answered Sep 28 '22 19:09

paxdiablo