T_Specht

Q: Not able to access localhost via local IP

I want to connect to my local Web Server (NodeJS server) which runs on my MacBook with my iPhone.

On my Mac I can access the server via http://localhost:3000/. Now all it should take is to replace localhost with my Mac's local IP address like this http://192.168.0.13:3000/. However, on my iPhone I cannot access the server this way and even when I try to open http://192.168.0.13:3000/ on my Mac there is no connection being established.

This is definitely a problem with my Mac and not with my program because when I run the server on Windows and try to connect to it with the local IP address it works just fine.

Also trying this in another Wi-Fi Network does not help or changing the port does not change anything either.

I am using Mac OSX 10.11.5 and my firewall is turned off.

How can I solve this problem?

My Routing Tables (netstat -r)

Routing tables

 

 

Internet:

Destination        Gateway            Flags        Refs      Use   Netif Expire

default            192.168.0.1        UGSc          139        0     en0

127                localhost          UCS             0        0     lo0

localhost          localhost          UH             18    89045     lo0

169.254            link#4             UCS             0        0     en0

192.168.0          link#4             UCS             0        0     en0

192.168.0.1/32     link#4             UCS             1        0     en0

192.168.0.1        88:f7:c7:ca:46:61  UHLWIir       139        0     en0   1197

192.168.0.13/32    link#4             UCS             0        0     en0

224.0.0            link#4             UmCS            1        0     en0

224.0.0.251        1:0:5e:0:0:fb      UHmLWI          0        0     en0

255.255.255.255/32 link#4             UCS             0        0     en0

 

 

Internet6:

Destination        Gateway            Flags         Netif Expire

localhost          localhost          UHL             lo0

fe80::%lo0         localhost          UcI             lo0

localhost          link#1             UHLI            lo0

fe80::%en0         link#4             UCI             en0

tims-macbook-pro.l 80:e6:50:9:1b:70   UHLI            lo0

fe80::%awdl0       link#8             UCI           awdl0

tims-macbook-pro.l 2:6d:32:cd:9f:bd   UHLI            lo0

ff01::%lo0         localhost          UmCI            lo0

ff01::%en0         link#4             UmCI            en0

ff01::%awdl0       link#8             UmCI          awdl0

ff02::%lo0         localhost          UmCI            lo0

ff02::%en0         link#4             UmCI            en0

ff02::%awdl0       link#8             UmCI          awdl0

My hosts file (/etc/hosts)

##

# Host Database

#

# localhost is used to configure the loopback interface

# when the system is booting.  Do not change this entry.

##

127.0.0.1       localhost

255.255.255.255 broadcasthost

::1     localhost

fe80::1%lo0     localhost

MacBook Pro (Retina, 15-inch, Mid 2014), OS X El Capitan (10.11.5)

Posted on Aug 31, 2016 8:56 AM

Close

Q: Not able to access localhost via local IP

  • All replies
  • Helpful answers

  • by BobTheFisherman,

    BobTheFisherman BobTheFisherman Sep 1, 2016 8:09 AM in response to T_Specht
    Level 6 (15,269 points)
    Sep 1, 2016 8:09 AM in response to T_Specht

    There are a couple of possibilities. First check your apache conf file to ensure your web server is listening on 192.168.0.13 port 3000. network your computer is connected to. Second, 192.168.xxx.xxx addresses are not routable so make sure your phone is connected to the same local network as your computer when you try to access your web server.

  • by T_Specht,

    T_Specht T_Specht Sep 1, 2016 10:33 AM in response to BobTheFisherman
    Level 1 (4 points)
    Notebooks
    Sep 1, 2016 10:33 AM in response to BobTheFisherman

    Thanks for the answer but I am almost a hundert percent sure that it is not a problem with my web server. I tried accessing a MAMP (Apache) Server which, by the conf file, allowed all incoming connections and I tried a NodeJS server. Both did not work. The NodeJS server, however, worked perfectly fine on Windows and I could access it with my iPhone which is on the same network.

    So I really think this problem is caused by the Mac. Also, I used Fing on my iPhone to scan my Network for available services and it found the server. However, connecting is not possible.

    Do you have any other solutions for the problem?

  • by BobTheFisherman,

    BobTheFisherman BobTheFisherman Sep 1, 2016 10:56 AM in response to T_Specht
    Level 6 (15,269 points)
    Sep 1, 2016 10:56 AM in response to T_Specht

    It is not likely that the computer itself is causing the issue. Default settings on your computer will allow a correctly configured server to work locally on your LAN. I suggest revisiting your MAMP settings.

  • by T_Specht,

    T_Specht T_Specht Sep 1, 2016 1:20 PM in response to BobTheFisherman
    Level 1 (4 points)
    Notebooks
    Sep 1, 2016 1:20 PM in response to BobTheFisherman

    It is most likely not the MAMP server because the same error occurs with a NodeJS server. Is there a way to reset to default configuration in the OS?