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?
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With