Reputation: 18559
I'm developing a web app using Django. When I run the command manage.py runserver
, I can access the website at http://localhost (127.0.0.1:8000)
. Is there a security risk if I keep it running 24/7 while doing the development. Do I need to block this port on my router so that it isn't accessible from outside?
Upvotes: 1
Views: 277
Reputation: 15104
No there is no security risk since it runs in the localhost interface (127.0.0.1) so it is accessible only from your computer.
There would be a security risk only if you were running it to the 0.0.0.0 interface (manage.py runserver 0.0.0.0:8000).
To elaborate a little more on my answer: When a an application that listens for connections (the django development server for instance) wants to run it must define the interface (IP) and the port (TCP) that it wants to bind to - meaning where it will start listening for new connections.
Now, all computers have an interface named localhost with the IP address 127.0.0.1. This is the loopback interface and it does not need any actual hardware to be enabled. Only clients running from the same computer can connect to this interface. So if you start a number of servers that are only bound to 127.0.0.1 you are completely safe and shouldn't worry about safety.
Beyond the localhost interface, your computer can have a number of other network interfaces, each one with one - or more - IPs. Let's take a case where you have for instance two network cards in your computer that are connected to two different networks: One with an IP of 192.168.1.1 and the other with an ip if 192.168.2.1. When you start a server you can bind it to the IP 192.168.1.1, so only computers from the network 192.168.1.x will be able to connect to it or to the IP 192.168.2.1 so that only computers from the network 192.168.2.x will be able to connect to it. Also, you may bind it to the 0.0.0.0 IP which means that it will accept connections from all interfaces !
I must say that I am not a network engineer so the terminology might not be 100% correct.
I hope it is more clear now if you have any questions just ask !
Upvotes: 5