简体   繁体   中英

How to run django localhost on another system in same private network

I am using django for my project. Now I want to access my project. Both my system and the another one are in the same private network. I am using VPN to connect to the network. How can I access http://localhost:8000 from another system?

What all I did:

  1. ALLOWED_HOSTS = ['*']
  2. DEBUG = False
  3. python manage.py runserver 0.0.0.0:8000
  4. Using my IP (say 192.168.xy) from another system to access the page, but no use - I still couldn't access the page. (I can access the page http://192.168.xy:8000/home from the browser of the same system though)

My main motive is to launch the application and to be able to use it from a system - both server and client machine are in same private network connected either by VPN or LAN

Use IP with port number - 192.168.xy: port . It should work.

If not, check your application is listening on the port using command lsof -i on your application machine.

mention your ip in ALLOWED_HOSTS in settings.py file like: ALLOWED_HOSTS=['192.168.x.y','localhost']

then run:

python manage.py runserver 0.0.0.0:portnumber

then you can access your ip at any local machine

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM