Can't get Django to server its dev server on my LAN

995 views Asked by At

I really try not to ask questions on here, but I've been googling for a bit now and can't find the answer or another method to try. I have a CentOS box at my house hooked to a router. I've assigned it a static IP of 192.168.1.140. Because I'm lazy, I just ssh into it. When I'm goofing around with Django (learning Django/Python at the moment) and I run python manage.py runserver with a variety of IP address, I can't get my browser to access that box. I've tried

python manage.py runserver 0.0.0.0:8000
python manage.py runserver 8000
python manage.py runserver localhost:8000
python manage.py runserver 192.168.1.140:8000
python manage.py runserver 192.168.1.255:8000
python manage.py runserver 192.168.1.0:8000
python manage.py runserver 192.168.1.1:8000 #this errors out and says I can't use this IP address although this is the IP I use to access the router

When I run netstat -tln in another terminal I can indeed verify that it's listening on port 8000 to the specified address. In iptables I've run it just how it is and I've run it through tcp --dport 8000 and --sport 8000 with the same results. Just can't quite seem to crack the code. I've also setup port forwarding on my router so port 8000 is directed at 140. Is there a log somewhere I can check that I can't find on google? What am I missing?

Whilst googling I came close to an answer but I think it must be something else.

I'm running Python 2.7.5 and Django 1.5.2 through virtualenv if you need to know. Is virtualenv my issue? Thanks y'all

1

There are 1 answers

2
Migisha On

According to this documentation, the right approach would be to set the python manage.py runserver xxx.xxx.xxx.xxx:yyyy to the IP address of the port you're using [Wi-Fi or Ethernet]. If the other devices are connected to the same LAN, then they should be able to access your Python VirtualEnv straight from their browsers. Worked just fine on mine. Also, I use DHCP - don't know if it changes anything. Just thought I'd mention that.