views:

74

answers:

3

It seems that Rails and Django can both start up the server binding to an IP, either

0.0.0.0, 127.0.0.1, or 192.168.1.2  <-- the last one is my local IP

are there other choices? It seems that 0.0.0.0 and 192.168.1.2 can let a Virtual PC on the same machine access this website, while 127.0.0.1 cannot.

However, if it is just the same notebook, using localhost:3000 (for Rails), then it doesn't matter. But either case, 0.0.0.0:3000 won't work.

How does it work? What are the meanings of using 0.0.0.0 vs 127.0.0.1 vs 192.168.1.2?

+1  A: 

0.0.0.0 binds to all IP addresses. Any other address binds to that particular interface.

Delan Azabani
A: 

If you start the server on 127.0.0.1, it is only listening on localhost; if you start it on 0.0.0.0, it is listening on any IP (eg your local IP).

For local dev, this is fine - but otherwise, no one but the local machine will be able to see it.

mway
+4  A: 

Binding to 0.0.0.0 means to listen to all interfaces.

Binding to 127.0.0.1 means to listen to the loopback interface.

Dan