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

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

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

Are there any other options? It seems that 0.0.0.0 and 192.168.1.2 can allow a virtual PC on the same computer to access this website, while 127.0.0.1 cannot.

However, if this is only the same laptop using localhost: 3000 (for Rails), then that doesn't matter. But in any case, 0.0.0.0haps000 will not work.

How it works? What are the usage values โ€‹โ€‹of 0.0.0.0 vs 127.0.0.1 vs 192.168.1.2?

+5
source share
3 answers

Binding to 0.0.0.0 means listening on all interfaces.

127.0.0.1 .

+16

0.0.0.0 IP-. .

+1

If you start the server at 127.0.0.1, it only listens on localhost; if you run it on 0.0.0.0, it listens on any IP address (for example, your local IP address).

This is fine for the local developer - but otherwise, no one but the local machine will be able to see it.

+1
source

All Articles