Search code examples
pythondjangoubuntuubuntu-14.04lan

Django server on local ubuntu server cannot be reached from another windows machine


I am trying to deploy Django project on Ubuntu 14.04.2 LTS with

python manage.py runserver 0.0.0.0:8000

also tried

python manage.py runserver 192.168.0.103:8000

The server starts, however i cannot reach it on another machine(Windows 7) in the same LAN. I am thinking that LAN is working properly, because i use ssh to connect ubuntu server and working through it. The /etc/network/interfaces file:

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp

The ifconfig:

eth0      Link encap:Ethernet  HWaddr 00:17:31:e5:99:89
          inet addr:192.168.0.103  Bcast:192.168.0.255  Mask:255.255.255.0
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0

I tried accessing 192.168.0.103:8000 in browser on Windows but nothing. What am i doing wrong?


Solution

  • If you can SSH in then most likely this means that your 8000 port is not open on the server, try this Ubuntu iptables guide

    If your SSH works, then you can also use port forwarding through SSH

    ssh user@server -L 8000:server:8000

    This is the the ssh user@host -L localport:host:hostport format

    This will forward the 8000 port from your server, to your 8000 port locally, through the SSH tunnel, and in which case on your browser you'd use 127.0.0.1:8000 or localhost:8000(as opposed to using the host/IP of the server)