问题描述
我有一个运行在127.0.0.1:8000上的Django服务器
I have a Django server running on 127.0.0.1:8000
当我尝试从同一台计算机访问它时,便可以打开我的应用程序.但是,当我尝试使用machinename:8000从另一台计算机访问此应用程序时,它说无法访问此站点"
When I try to access it from the same machine then I am able to open my application. But when I try to access this app from a different machine by using machinename:8000 then it says 'This site can't be reached'
在我的settings.py中,我有
In my settings.py, I have
和
这与上面的配置有关吗?
Is this related to above configuration?
推荐答案
要与同一局域网中的其他计算机连接,必须使用以下命令运行服务器:
To connect with the other computers in the same local network as you you have to run your sever using :
manage.py runserver 0.0.0.0:8000
然后在您的settings.py中输入:
And in your settings.py put :
ALLOWED_HOSTS = ['*']
您必须知道您的PC的本地IP地址,并在最后添加:8000"进行连接.要了解您的计算机IP地址,请执行以下操作:重击:$ ifconfigWindows:ipconfig
And you have to know your local IP adress of your pc and connect adding ":8000" at the end. To know your computer IP adress:Bash : $ ifconfigWindows : ipconfig
这篇关于Django应用无法从其他计算机打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!