2

I am running a rails web app server bound to 0.0.0.0 on port 80 like so:

sudo rails s --port=80 --bind=0.0.0.0

I can access it at my private address http://192.168.0.13/, normally I can access at the loopback address http://127.0.0.1 / http://localhost. However for some reason the loopback address is not pointing to this private address. I think this problem is related to a VM configured on my machine as this problem started happening after I setup the VM.

The vagrant VM setup (which I didn't configure) is running a second web app server which I can access at http://127.0.0.1. However even when I turn off this vagrant VM I still can't access this rails web app server mentioned above at the loopback address.

What is the vagrant VM doing to configure the loopback to itself?

How can I configure the private address that the loopback address points to?

Here is my ifconfig if it helps:

lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
    options=3<RXCSUM,TXCSUM>
    inet6 ::1 prefixlen 128
    inet 127.0.0.1 netmask 0xff000000
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
    nd6 options=1<PERFORMNUD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    ether 4c:8d:79:d7:a9:e4
    inet6 fe80::4e8d:79ff:fed7:a9e4%en1 prefixlen 64 scopeid 0x4
    inet 192.168.0.13 netmask 0xffffff00 broadcast 192.168.0.255
    nd6 options=1<PERFORMNUD>
    media: autoselect
    status: active
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    options=10b<RXCSUM,TXCSUM,VLAN_HWTAGGING,AV>
    ether a8:20:66:5a:9b:c7
    nd6 options=1<PERFORMNUD>
    media: autoselect (none)
    status: inactive
fw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 4078
    lladdr 10:dd:b1:ff:fe:4f:ee:4c
    nd6 options=1<PERFORMNUD>
    media: autoselect <full-duplex>
    status: inactive
en2: flags=963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX> mtu 1500
    options=60<TSO4,TSO6>
    ether d2:00:14:fe:e4:c0
    media: autoselect <full-duplex>
    status: inactive
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
    ether 0e:8d:79:d7:a9:e4
    media: autoselect
    status: inactive
awdl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1484
    ether de:fa:c4:c2:1b:f7
    inet6 fe80::dcfa:c4ff:fec2:1bf7%awdl0 prefixlen 64 scopeid 0x9
    nd6 options=1<PERFORMNUD>
    media: autoselect
    status: active
bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    options=63<RXCSUM,TXCSUM,TSO4,TSO6>
    ether 4e:8d:79:7d:7e:00
    Configuration:
        id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
        maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
        root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
        ipfilter disabled flags 0x2
    member: en2 flags=3<LEARNING,DISCOVER>
            ifmaxaddr 0 port 7 priority 0 path cost 0
    nd6 options=1<PERFORMNUD>
    media: <unknown type>
    status: inactive
vboxnet0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    ether 0a:00:27:00:00:00
    inet 172.28.128.1 netmask 0xffffff00 broadcast 172.28.128.255

In the Vagrantfile I see it has configured some port forwarding:

  system('sudo pfctl -E')
  system('echo "
    rdr pass on lo0 inet proto tcp from any to 127.0.0.1 port 80 -> 127.0.0.1 port 9080
    rdr pass on lo0 inet proto tcp from any to 127.0.0.1 port 443 -> 127.0.0.1 port 9443
    " | sudo pfctl -f - > /dev/null 2>&1; echo "==> Fowarding Ports: 80 -> 9080, 443 -> 9443"')
david_adler
  • 129
  • 7
  • In your question there is no info to explain your choice of tags. Imo is more a configuration issue of the app server than a networking related issue (with networking i mean routing, firewalling and the like) because the behaviour you describe is fine if the app is configured to respond on a specific ip only. Double check the documentation of the app server and verify the config of the app itself. – Paolo May 22 '16 at 05:29

1 Answers1

1

127.0.0.1 is your loopback. It is always local to the machine you are on. Creating a VM means it is a new machine and it has its own internal 127.0.0.1. You could create 50 VM's and they're each going to have their own internal 127.0.0.1 and no way for the computer to know which one you want. So you should only be able to get to web pages on the VM's at their routable IP address, not 127.0.0.1.

chicks
  • 3,793
  • 10
  • 27
  • 36