python – how to access my from android tablet-ThrowExceptions

Exception or error:

I am developing a webpage in django (on my pc with windows 7) and now i need to test some pages in tablet pcs. suddenly the thought came if i can have an access to my localhost in windows from android tablet. is that possible? I am in the same wifi connection in both devices at home.

i read a lot questions and answers regarding this issue in stackoverflow and other places, but none of them gave me some concrete solutions.

I have samsung tab 2 10.1 with android 4.0.4.

appreciate any help, thanks

How to solve:

You can find out what the ip address of your PC is with the ipconfig command in a Windows command prompt. Since you mentioned them being connected over WiFi look for the IP address of the wireless adapter.

Since the tablet is also in this same WiFi network, you can just type that address into your tablet’s browser, with the :8000 appended to it and it should pull up the page.


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:

# Only handle requests which are made to the IP address

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

runserver # handle all requests

So, if your IP address is

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

I do think it important to note that 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.


Though this thread was active quite a long time ago. This is what worked for me on windows 10. Posting it in details. Might be helpful for the newbies like me.

  1. Add ALLOWED_HOSTS = ['*'] in django file
  2. run django server with python I used 9595 as my port.
  3. Make firewall to allow access on that port:

    • Navigate to control panel -> system and Security -> Windows Defender Firewall

    • Open Advanced Settings, select Inbound Rules then right click on it and then select New Rule

    • Select Port, hit next, input the port you used (in my case 9595), hit next, select allow the connections
    • hit next again then give it a name and hit next for the last time.
  4. Now find the ip address of your PC.

    • Open Command Promt as adminstrator and run ipconfig command.
    • You may find more than one ip addresses. As I’m connected through wifi I took the one under Wireless LAN adapter WiFi. In my case it was
    • Note that this ip may change when you reconnect to the network. So you need to check it again then.
  5. Now from another device (pc, mobile, tablet etc.) connected to the same network go to ip_address:YOUR_PORT (in my case

    Hopefully you’ll be good to go !

### is a loopback address that means, roughly, “this device”; your PC and your android tablet are separate devices, so each of them has its own In other words, if you try to go to on your Android tab, it’s trying to connect to a webserver on the Android device, which is not what you want.

However, you should be able to connect over the wifi. On your windows box, open a command prompt and execute “ipconfig”. Somewhere in the output should be your windows box’s address, probably or something similar. You tablet should be able to see te Django server at that address.


If both are connected to the same network, all you need to do is provide the IP address of your server (in your network) in your Android app.


need to know the ip address of your machine ..
Make sure both of your machines (tablet and computer) connected to same network – say your machine address

do this : — from your tablet

this is it !!!


Tested using easy EasyPHP DevServer 14.1.
The trick is you must first add your local ip address to the Apache server to listen to it.

Right click on the tray icon, go to “Configuration” -> “Apache” in the “httpd.config”

# Change this to Listen on specific IP addresses as shown below to 
# prevent Apache from glomming onto all bound IP addresses.
Listen  <<-- ADD THIS LINE

Then go to your Control Panel and deactivate your Windows Firewall or add your Smartphone/Tablet Ip Address to the exception.

That’s it. I hope it helps.

The IP Address may be different from yours. 192.168.0.X


I’ve struggled with this problem myself, and I couldn’t figure out what it was, since it worked perfectly on my iPhone, I decided to look into the problem and find a quick solution.
My local machine is a Mac OSX 10.10+, one option would have been to start an Apache server, but that’s super unhandy – changing the DocumentRoot every time you want to check something quickly on your Android device. Besides that, changing the DocumentRoot is a pain in the a** on Mac OSX 10.10.

If you want to use:

python -m SimpleHTTPServer

on your Android, do this:

sudo python -m SimpleHTTPServer [ANY PORT YOU WANT, BUT NOT 8000]

I hope this helps.

cheerz -Pit

Leave a Reply

Your email address will not be published. Required fields are marked *