python 通过 localhost 访问时无法通过 ip 地址访问 django 应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1493479/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cannot access django app through ip address while accessing it through localhost
提问by Mert Nuhoglu
I have a django app on my local computer. I can access the application from a browser by using the url: http://localhost:8000/myapp/
我的本地计算机上有一个 django 应用程序。我可以使用以下网址从浏览器访问该应用程序:http://localhost:8000/myapp/
But I cannot access the application by using the ip of the host computer: http://193.140.209.49:8000/myapp/I get a 404 error.
但是我无法使用主机的 ip 访问应用程序:http: //193.140.209.49: 8000/myapp/我收到 404 错误。
What should I do? Any suggestions?
我该怎么办?有什么建议?
回答by Edward Dale
I assume you're using the development server. If so, then you need to specifically bind to your external IP for the server to be available there. Try this command:
我假设您正在使用开发服务器。如果是这样,那么您需要专门绑定到您的外部 IP,以便服务器在那里可用。试试这个命令:
./manage.py runserver 193.140.209.49:8000