[Fixed]-Testing Django website on iphone

16👍

In addition to using the correct IP, your runserver command should listen on 0.0.0.0(all IPs).

runserver 0.0.0.0:8000
👤Kekoa

9👍

Below steps worked for me on MAC OS 10.10.3

  1. python manage.py runserver 0.0.0.0:8000
  2. in terminal window “ipconfig getifaddr en0” returned IP address 10.0.1.22
  3. open browser in Iphone/Ipad “http://10.0.1.22:8000

3👍

You need to use the IP address AND port that the runserver is running on… this is usually :8080 or whatever number that follows the IP it reports when it runs the server.

so if the runserver command reports…

http://127.0.0.1:8000/

then if your IP is 192.168.0.2 use…

http://192.168.0.2:8000/

If for some reason you want to set the port manually, runserver [port] works…

0👍

FOR WINDOWS USERS WHO MIGHT RUN INTO THE SAME PROBLEM.

STEP 1: run python manage.py runserver 0.0.0.0:8000

STEP 2: run ipconfig on your windows’ computer cmd

STEP 3: in your settings.py file change this line of code like this ALLOWED_HOSTS = [‘*’]

STEP 4: type http:// then your ip address that you got from STEP 2 then : and then port 8000, something like this (http://192.168.0.2:8000/), but the ip address should be your computer ip address.

Leave a comment