Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serve Django project on local WiFi Network

Tags:

python

django

I used

python manage runserver 0.0.0.0:8000

to start the server so that I can access the project from other computers on my wifi network, but when i browse to internet-ipaddress:8000 on an another computer, the project doesn't load. Am I missing a setting?

like image 435
Ali Avatar asked Nov 29 '22 17:11

Ali


1 Answers

Assuming all the machines can see eachother ...

get the IP address of the machine you are running runserver on. For example run ifconfig at the console.

ifconfig

eth0      Link encap:Ethernet  HWaddr 10:1e:72:b8:2a:4b  
              inet addr:192.168.1.2  Bcast:192.168.1.255  Mask:255.255.255.0
              ...

check if you are running a firewall. For example

sudo ufw status

if active, you need to open port 8000 so, again at the console, run

sudo ufw allow 8000/tcp

then start the runserver (or runserver_plus if using django-extensions)

python manage.py runserver_plus 192.168.1.2:8000

open a browser on another machine

http://192.168.1.2:8000/admin
like image 64
erikvw Avatar answered Dec 06 '22 18:12

erikvw