How to access the local Django webserver from outside world

前端 未结 9 1678
天命终不由人
天命终不由人 2020-12-02 04:06

I followed the instructions here to run Django using the built-in webserver and was able to successfully run it using python manage.py runserver. If I access 1

9条回答
  •  时光取名叫无心
    2020-12-02 04:31

    You have to run the development server such that it listens on the interface to your network.

    E.g.

    python manage.py runserver 0.0.0.0:8000
    

    listens on every interface on port 8000.

    It doesn't matter whether you access the webserver with the IP or the hostname. I guess you are still in your own LAN.
    If you really want to access the server from outside, you also have to configure your router to forward port e.g. 8000 to your server.


    Check your firewall on your server whether incoming connections to the port in use are allowed!

    Assuming you can access your Apache server from the outside successfully, you can also try this:

    • Stop the Apache server, so that port 80 is free.
    • Start the development server with sudo python manage.py runserver 0.0.0.0:80

提交回复
热议问题