Can't Access My Laptop's Localhost Through An Android App
So I did a research before posting this and the solutions I found didn't work, more precisely: -Connecting to my laptop's IPv4 192.168.XXX.XXX - didn't work -Conecting to 10.0.2.2
Solution 1:
Have you started the server like this?
python manage.py runserver 0.0.0.0:8000
Then, try to connect to 192.168.XXX.XXX:8000
Solution 2:
I tried the above, but failed to work in my case. Then with running python manage.py runserver 0.0.0.0:8000 I also had to add my IP to ALLOWED_HOSTS in settings.py, which solved this issue.
eg. Add your ip to allowed hosts in settings.py ALLOWED_HOSTS = ['192.168.XXX.XXX']
Then run the server python manage.py runserver 0.0.0.0:8000
Solution 3:
Others have already given the answer but those solutions didn't work for me when I was running Django server on Ubuntu and was trying to access it from my Mobile app.
Following is what worked for me:
Step 1: Run server to access it from your IP
python manage.py runserver 0.0.0.0:8000
Step 2: Open port in firewall (Missing step in above given answers - Needed for Ubuntu)
$ sudo ufw enable$ sudo ufw allow 8000
Post a Comment for "Can't Access My Laptop's Localhost Through An Android App"