开发者

What is the difference between starting a server binding to 0.0.0.0 vs 127.0.0.1?

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 ca开发者_开发问答nnot.

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?


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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜