How to access my 127.0.0.1:8000 from Android tablet

So, there are a couple of issues it seems. The question most of the answers are addressing is “how do you connect to another server in your local network?” (or variants). There are two answers, you can use the computer’s IP directly, or you can use the computer’s name (you may need to append .local). For example, my computer is xavier.local.

The second issue is that you seem to be addressing is that runserver is not accessible via other computers on the network (this is your actual question). The reason is that by default Django’s runserver will only acknowledge requests from the machine which is calling them. This means that the default settings would make it so that you would only be able to access the server from Windows (and they did this on purpose for security reasons). In order for it to listen to other requests you have two options:

runserver 192.168.1.101:8000 
# Only handle requests which are made to the IP address 192.168.1.101

Or (and this is easier when dealing with more than one environment):

runserver 0.0.0.0:8000 # handle all requests

So, if your IP address is 192.168.1.101:

runserver # only requests made on the machine will be handled
runserver 127.0.0.1 # only requests made on the machine will be handled
runserver 192.168.1.101 # handles all requests (unless IP changes)
runserver 192.168.1.100 # does not handle any requests (wrong IP)
runserver 0.0.0.0 # handles all requests (even if the IP changes)

I do think it important to note that 0.0.0.0 is realistically not a security question when dealing with a local, development machine. It only becomes a significant problem when working on a large app with a machine which can be addressed from the outside world. Unless you have port forwarding (I do), or something wonky like that, you should not be too concerned.

Leave a Comment