Unable to access django app on other android devices on my hotspot network

Question:

I created the django app and hosted the same on my laptop which was connected to my android mobile hotspot.

Then I got the IP of my machine, using ipconfig

Wireless LAN adapter Wi-Fi:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::2d4e:f2c4:bc88:e67e%5
   IPv4 Address. . . . . . . . . . . : 192.168.43.69
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.43.1

then I added the same to

ALLOWED_HOSTS = ['192.168.43.69']

and ran the server using

python manage.py runserver 192.168.43.69:8000

now when I am accessing the same on my laptop, I am able to access the device but when I am trying to access the same on my mobile device I am getting the same typical chrome connection error

The site can't be reached
192.168.43.69 took too long to respond
ERR_CONNCTION_TIMED_OUT

How can I resolve the same?

Asked By: Himanshuman

||

Answers:

you should run the server by using

python manage.py runserver 0.0.0.0:8000

That way only you can access it from outside host. You still can use your host ip address to access the application.

ie: 192.168.43.69
Answered By: Yasii

Had to turn off windows defender for it to receive incoming traffic

enter image description here

One thing I still didn’t get was since the request coming to my device were all internal from the device connected to my router, still why windows defender was blocking the incoming requests?

Answered By: Himanshuman

Here is what I found with the help of Himanshuman’s and Yasii’s answers.
I got things work for me i am mentioning below:

  1. get you IP address using ipconfig

  2. Add this IPV4 IP address to the ALLOWED_HOSTS list in setting.py

  3. turn off the firewall on you system from settings.

  4. Next step is try running the localhost using python manage.py runserver 0.0.0.0:8000

  5. Now go to phone and type yourIP:8000 and your project will run in your phone.

    For example 192.168.45.100:8000 will run the localhost in your phone.

This is how things worked for me. steps are in cronological order and recommended to be executed one after another

Answered By: Sampat Aheer