About IP 0.0.0.0 in Django

Zhu Tao picture Zhu Tao · Oct 25, 2009 · Viewed 31.6k times · Source

We've got a server over which we're running a Django powered site. Since we want to test the site, we're using Django's build-in development server (i.e runserver). But I'm curious about the ip of the following command:

python manage.py runserver 0.0.0.0:80

It results in a running site we can visit using server's ip remotely.
But when using 127.0.0.1 instead:

python manage.py runserver 127.0.0.1:80

No one can visit the site with the sever's ip from another pc.

So why? What does 0.0.0.0 exactly means (Google says it's the default route) ? Why can't 127.0.0.1:80 be accessed remotely?

Answer

Paul Tomblin picture Paul Tomblin · Oct 25, 2009

0.0.0.0:80 is a shortcut meaning "bind to all IP addresses this computer supports". 127.0.0.1:80 makes it bind only to the "lo" or "loopback" interface. If you have just one NIC with just one IP address, you could bind to it explicitly with, say, 192.168.1.1:80 (if 192.168.1.1 was your IP address), or you could list all the IPs your computer responds to, but 0.0.0.0:80 is a shortcut for that.