在通过本地主机访问时,无法通过ip地址访问django应用程序 [英] Cannot access django app through ip address while accessing it through localhost

查看:380
本文介绍了在通过本地主机访问时,无法通过ip地址访问django应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的本地电脑上有一个django应用程序。我可以通过使用URL访问浏览器中的应用程序: http:// localhost:8000 / myapp /



但是我无法使用主机的ip访问应用程序: http://193.140.209.49:8000/myapp/ 我收到404错误。



我该怎么办?任何建议?

解决方案

我假设您正在使用开发服务器。如果是这样,那么您需要专门绑定到您的外部IP,以便服务器可用。尝试以下命令:

  ./ manage.py runserver 193.140.209.49:8000 


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/

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.

What should I do? Any suggestions?

解决方案

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:

./manage.py runserver 193.140.209.49:8000

这篇关于在通过本地主机访问时,无法通过ip地址访问django应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆