5

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?

Ali
  • 4,311
  • 11
  • 44
  • 49

6 Answers6

11

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
erikvw
  • 416
  • 3
  • 11
6

What do you mean by internet-ipaddress? That sounds like you're using the external IP of your router. You should be using the IP of the particular machine you're serving from, which will be an internal address like 192.168.0.2.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
  • Hey Daniel, that worked. But does that mean there is no way to serve a a project to someone over the internet using the django webserver? – Ali Sep 24 '11 at 21:13
  • 1
    @Ali that's a different question. To do that, you need to configure port forwarding from your router to point the particular port to your server - that's when you can use the router's external IP. – Daniel Roseman Sep 24 '11 at 21:30
5

You should bind it to your local IP address. For example

python manage.py runserver 192.168.1.100:8000
infrared
  • 3,566
  • 2
  • 25
  • 37
2

Note: 192.168.2.5 is my ip. So, give your own

Open settings.py and add this to ALLOWED_HOSTS

ALLOWED_HOSTS = ['192.168.2.5']

Then run command

python manage.py runserver 192.168.2.5:8000

Allow access in the firewall's warning appeared.

Now access your host from the systems on same network.

arctic_Oak
  • 974
  • 2
  • 13
  • 29
2

You should check out solutions like Pagekite or Show Off as they're generally trivially easy to set up and offer a great deal of flexibility (and mobility) and provide a stable domain name to your localhost server.

Tony
  • 9,672
  • 3
  • 47
  • 75
Már Örlygsson
  • 14,176
  • 3
  • 42
  • 53
0

add 192.168.0.8 (or whatever your router ip is) as a string to ALLOWED_HOSTS list in settings then run server using python manage.py runserver 192.168.0.8:8000

Yusuf
  • 1
  • 1
  • 2