making django server accessible in LAN

前端 未结 3 1567
野趣味
野趣味 2020-12-04 20:49

I have installed django server and it can be accessible as below

http://localhost:8000/get-sms/
http://127.0.0.1:8000/get-sms/

suppose My i

相关标签:
3条回答
  • 2020-12-04 21:29

    To add @Depado 's answer you may need to add your LAN IP address to ALLOWED_HOSTS in the settings.py along with localhost. it would look like,

    ALLOWED_HOSTS = ["localhost", "192.168.8.160"]
    
    0 讨论(0)
  • 2020-12-04 21:30

    you can use https://forwardhq.com/ or https://ngrok.com/, these tools will expose your local web server to the internet/public.

    0 讨论(0)
  • 2020-12-04 21:46

    Running the Django Development Server
    This is what you're looking for. To help you further, here is what you should do:

    python manage.py runserver 0.0.0.0:8000
    

    By the way, this may be a duplicate of this question.

    Here is what the documentation says:

    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)
提交回复
热议问题