-5

I want to get my Android device to access a local web server running on my development machine on my desktop. In other words, I want to view my site in development on my phone.

Right now, on my desktop i just type localhost or 127.0.0.1 and i have access to my development environment.

Here are some details:

  • My desktop is directly connected with a cable to the router, no WIFI.
  • My Android phone is connected with WIFI
  • I have a TP-LINK Archer C7 router.

I have done the following:

  • Enter localhost in my phone ---- Failed!
  • Enter 127.0.0.1 in my phone ---- Failed!
  • Enter my desktop static IP in my phone ----- Failed!

Ive read in here that maybe i need to do something on my router, but i dont want to mess with all the options on my router. I want to make sure before messing around.

I've read the following post with no success:

(How can I access my localhost from my Android device?)

What to do? This should be very simple. Thanks

Marco
  • 2,687
  • 7
  • 45
  • 61
  • 2
    Possible duplicate of [Viewing localhost website from mobile device](https://stackoverflow.com/questions/17316692/viewing-localhost-website-from-mobile-device) – Martin De Simone Aug 06 '17 at 03:08
  • 1
    *localhost* is the local loopback address. It's only available on the **exact machine** where the code is located. If you need to access that location from another location, you'll need a publicly available IP address; you can't use *localhost*. (The **local** part is meaningful. It's **local** to the specific machine, and isn't available from anywhere else.) Entering *localhost* on your phone would be asking for the phone's local address, not your desktop. So would *127.0.0.1*. – Ken White Aug 06 '17 at 03:14
  • Try adding the port of your local web server when doing "Enter my desktop static IP in my phone" – Melchizedek Aug 06 '17 at 03:16
  • I've enter 192.168.0.XXX:80 on my phone with no sucess... – Marco Aug 06 '17 at 16:40
  • Changed the apache config file httpd.conf, i've added the line 192.168.0.XXX:80. Then, on my desktop i put 192.168.0.XXX:80 and it works. But on my mobile i get the error msg: "You don't have permission to access / on this server" It's not the old error msg (This site can't be reached) so i guess im making progress... – Marco Aug 06 '17 at 16:55

4 Answers4

1

If your web server has static content, you can copy the html/css/script/image files to a specific folder on your phone and open those from your phone.

Anyway, to get your device's browser to connect localhost website, you can do this :

Get the IP address of your computer, (Run > cmd > ipconfig)

+++And if localhost uses a specific port like localhost:1234 or else, you have to open the port on your firewall. Control Panel / System and Security / Firewall / Advanced

After that, you can connect to your website from mobile device by navigating to your ip. Such as: http://192.168.X.X:1234

Note: Are you sure both your devices are on the same network?

Don't forget to turn off mobile data on your phone, you need to rely on wifi.

Good luck.

newbee
  • 21
  • 6
  • My desktop is not on WIFI, i use an Ethernet cable from my desktop to the router. Tried 192.168.0.XXX:80 and even tried 192.168.0.XXX:8080 with no success. On my phone i get the msg: This site can't be reached... – Marco Aug 06 '17 at 16:28
  • both devices must be on the same local network for each to access each other, otherwise will need to go online on the internet to reach each other. – newbee Aug 07 '17 at 08:40
0

You may have to set port 80 and or 8080 to your file service in the router its self. I just noticed that my router allows me to call a specified program for a specified port number. It's just a thought.

0

Just go to CMD and type ipconfig then you will be able to see your pc's ip address. It may look something like 192.168.43.1. Now enter that along with the port address of your dev server in your phone then you will be good to go.

Iswar
  • 1
0

The link address http://192.168.X.X:1234 is correct, but the devices must be on the same network for the connection to be established. So both devices must be connected to wifi.

MuharremCetin
  • 51
  • 1
  • 5