DEV Community

ADEMOLA OGUNMOKUN
ADEMOLA OGUNMOKUN

Posted on • Updated on

How to connect your Django local development server to your mobile phone and test your app on your phone.

Building a web application in Django, the developer will often use the lightweight local development server to run the code and see the changes that have been made.

However it is often useful to see how the web app is doing on a particular mobile phone.

To do that, we need to connect the phone and the computer(local machine) on the same WiFi network. With Phone as the hotspot and the computer as WiFi.

Thereafter, click on your computer WiFi settings and note the IP address used.

For this example I am using 192.168.43.167 as the WiFi IP address.

On the Django project on your computer, click on the settings.py and navigate through to the Allowed Host. Change the empty list to the IP address noted earlier.

#Settings.py

Allowed Host = ["192.168.43.167"]
Enter fullscreen mode Exit fullscreen mode

Start your local development server by running

Python manage.py runserver IP:Port

For example, if the WiFi IP address noted earlier is 192.168.43.167.

Python manage.py runserver 192.168.43.167:8000
Enter fullscreen mode Exit fullscreen mode

On your phone browser input the IP address and the port number into the address bar to see your app.

http://192.168.43.167:8000

Top comments (0)