Access Django Website from another computer on same network

Viewed 8023

As the title says I want to access my django website on a different computer on the same network.

Both are running windows 10 connected to the same network. The host is connect through wifi and the other through ethernet cable.

I've changed the allowed host to my ip address.

ALLOWED_HOSTS = ['71.89.113.52', 'localhost', '127.0.0.1']

And ran the the server.

(VIRTEN) C:\Users\HP\Desktop\BBTennis\VIRTEN\src>python manage.py 0.0.0.0:8000

But I still can't access it on the other computer. When I go to 71.89.113.52:8000 or 0.0.0.0:8000, I get the message, This site can't be reached.

If possible, please present an answer with every direction I should take such as how to configure my network settings or django changes I must make.

4 Answers
  1. check both are on same network

  2. on PC1 windows go to cmd and type ipconfig and get IP-1 address

  3. PC1 : python manage.py runserver 0.0.0.0:8000

  4. go to other PC2 on same network and type IP-1_Address:8000

The 71.89.113.52 IP looks like a public ID address. I'd guess your request is going to a DNS outside your network and then being blocked on the way back in by the :8000 port being closed in your firewall.

I'd suggest using network tools such as traceroute or ipconfig on your computer to first confirm the IP address of the target computer, and then i'd using python manage.py runserver x.x.x.x:8000 to start the server. If you can't see your other computer already, then running a django server isn't going to change that.

In your settings.py, set

ALLOWED_HOSTS = ['*']

Then run:

python manage.py runserver 0.0.0.0:8000

Now make sure your machine firewall allows incoming and outgoing traffic. I use a Linux machine, so from control center go to firewall and allow both incoming and outgoing traffic.

Finally, on your local network machine, in the browser, type:

<<your host pc IP address:8000

This is it! It worked for me.

I would suggest having to use IPv4 address listed at Wireless LAN adapter Wi-Fi:, usually there are several adapters listed in ipconfig other that this, like I initially tried using one listed under Ethernet adapter VMware Network Adapter VMnet8 and that request didnot follow through in other device outside of my computer.

Related