4
votes

I have a django server running on my PC. I want to access the server through my android phone.How can I do that? I tried running

python manage.py runserver 0.0.0.0:8000.

After this, I can access server from my pc through PC's ip address, but not accessible through other device coonected to same wifi.

4
did you check to see if you have a firewall running on your pc?turbotux
Yes, I have firewall running on my pc but I enabled incoming connection for python.Atishay
Have you tried disabling the firewall completely?turbotux

4 Answers

17
votes

you need to do these steps

1. run python manage.py runserver 0.0.0.0:8000
2. figure out your ip address which is say 192.168.1.8
3. Add '192.168.1.8' to ALLOWED_HOSTS list in your settings.py file.
4. access 192.168.1.8:8000 on mobile.

I tried this, its working for me.

enter image description here

6
votes

can you try it python manage.py runserver youripadress:8000 [python manage.py runserver 192.168.0.1:8000]

2
votes

In your terminal run

ipconfig

and find the IPv4 address ,and if you are using Django go to settings.py and in the ALLOWED_HOST add the IPv4 address in the list.

In my case

ALLOWED_HOSTS = ['192.168.30.81', '127.0.0.1', '0.0.0.0', '192.168.167.206']

then run ( in my case )

python manage.py runserver 192.168.167.206:8000
0
votes

A related issue I ran into was in relation to this error:

"code 400, message Bad HTTP/0.9 request type ('\***\***\***\***\***\***\***\***\***') [time stamp] You're accessing the development server over HTTPS, but it only supports HTTP"

Just verify that this is the reason you are not able to view also. Of course you would see this in your server messages if so.