Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

About IP 0.0.0.0 in Django

Tags:

django

ip

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?

like image 624
Zhu Tao Avatar asked Oct 25 '09 17:10

Zhu Tao


People also ask

What does host 0.0 0.0 mean?

It tells a server to "listen" for and accept connections from any IP address. On PCs and client devices. A 0.0. 0.0 address indicates the client isn't connected to a TCP/IP network, and a device may give itself a 0.0. 0.0 address when it is offline.

What is Runserver in Django?

The runserver command is a built-in subcommand of Django's manage.py file that will start up a development server for this specific Django project.

Why does Python manage PY Runserver not work?

The site could be temporarily unavailable or too busy. Try again in a few moments. If you are unable to load any pages, check your computer's network connection. If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.


1 Answers

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.

like image 134
Paul Tomblin Avatar answered Oct 06 '22 00:10

Paul Tomblin