9

I'm trying to access a database that is hosted in a Mac localhost from my Android device which are both connected to the same network.

The localhost project is running at www.localhost:8000/

I've entered the IP: 192.168.1.1 (of my laptop connection) to my phone browser and I was able to see the root folder of my project.

However, when I attempted to run it at 192.168.1.1:8000/, I was not able to access anything and the web browser returned "Webpage not available".

So the issue now is that I can access the root folder using my Android device but I cannot access the "localhost server" of my laptop.

7
  • Does the phone browser support port numbers like :8000? Can you actually see something at 192.168.1.1:8000 with a browser on the Mac?
    – pavium
    Commented Jul 9, 2011 at 12:49
  • From another computer localhost1 refers to the other computer. You would need to connect to 192.168.1.1:8000 from the other computer (the phone). You probably know that, but I'm just trying to make it clear. BTW 192.168.1.1 sounds like the ADSL2+ modem I use, and the various computers in my LAN have IP addresses like 192.168.1.x where x>1
    – pavium
    Commented Jul 9, 2011 at 12:56
  • Hi Pavium , I've connected using a windows laptop and its also fine. I can access 192.168.1.1 using the windows laptop within hte same network. But I cannot access 192.168.1.1:8000 though ... the web service in the mac is running at localhost:8000 and i was hoping to access it using the windows laptop at 192.168.1.1:8000 , any way it may work?
    – jamen
    Commented Jul 9, 2011 at 13:01
  • I'm running out of ideas, but I think the situation is clearer now. Maybe this question would be answered better on ServerFault? I wonder if it could be flagged, and migrated to SF by a moderator?
    – pavium
    Commented Jul 9, 2011 at 13:08
  • Hi pavium thanks for helping ! SF is which forum ? StackoverFlow ?
    – jamen
    Commented Jul 9, 2011 at 13:27

2 Answers 2

6

I would imagine this is because your server is set to listen on the loopback interface only. You can confirm this by looking at the output of netstat -an. As an example of output

Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN     

This means that this server (bind nameserver in this case) is only LISTENing for connections on port 53 on the address 127.0.0.1.

You can get around this by either configuring the server to listen on the 192.168.1.1 address or to do something like ssh tunneling to get around this. It's a bit of an old article (2007) but the contents is still relevent: http://magazine.redhat.com/2007/11/06/ssh-port-forwarding/ (mirror).

I personally use Putty to do port forwarding of this ilk on my windows hosts.

4
  • hi Drav ! THanks ! I did the netstat and it shows 127.0.0.1.8000. How may i configure the server to listen on the 192.168.1.1 address ? is it through the httpd.conf file ? or through the etc/hosts file ?
    – jamen
    Commented Jul 9, 2011 at 13:34
  • @jamen - Ask this as another question.
    – Nifle
    Commented Jul 9, 2011 at 13:36
  • Hi Nifle , what do you mean ? Is this question in the wrong forum ? Sorry :S
    – jamen
    Commented Jul 9, 2011 at 13:41
  • 3
    Jamen, @Nifle means you should ask about how to configure the server as a separate question. This question seems to have been answered because you accepted Drav Sloan's answer.
    – pavium
    Commented Jul 9, 2011 at 14:02
0

I had the same issue, I was on a windows 10 laptop using ssh agent to connect to my centos 8 server. I hosted a local site on the centos 8 server and to access that site on a localhost from my server. I typed in the server IP address and included the port number of where my localhost runs.

remote server ip:8080 # 8080 is the localhost port where my site is running on the remote server,

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .