Access from external to python development server

前端 未结 2 1603
天命终不由人
天命终不由人 2021-02-14 02:50

I can\'t access externally to python development server, I have a very small django project running on my machine, and now I want to enable computers in the same LAN have access

相关标签:
2条回答
  • 2021-02-14 02:57

    How are you running the server?
    Have you tried something like this?

    manage.py runserver 0.0.0.0:8080
    

    From the documentation:

    Note that the default IP address, 127.0.0.1, is not accessible from other machines on your network. To make your development server viewable to other machines on the network, use its own IP address (e.g. 192.168.2.1) or 0.0.0.0.

    0.0.0.0 means: bind to all IP addresses this computer supports. So, as TheSingularity says, you'll then be able to access your Django app by entering the private IP address usually beginning with 192.168.*; which is not accessible from the Internet.

    0 讨论(0)
  • 2021-02-14 03:02

    run your django app like this:

    ./manage.py runserver 0.0.0.0:8800 
    

    you can access now your project from other machine like this:

    http://<ip_address_machine_where_project>:8800
    
    0 讨论(0)
提交回复
热议问题