django - 无法访问我通过 ssh 连接到的服务器上的开发服务器

标签 django server centos

我正在从 Centos 服务器部署 django 应用程序。当我做 python3.6 manage.py runserver 8000命令它启动一个开发服务器没问题。我无法从本地计算机访问此页面进行测试。

所以我采取的步骤是:我通过执行 ssh <user>@url.com SSH 进入服务器然后使用上述命令运行开发服务器。然后,我在笔记本电脑上的浏览器中输入 url.com:8000,然后会出现 Unable to connect
在运行我的 apache 服务器进行生产时,我也遇到了这个问题。我将服务器放在服务器上我没有问题,但我无法访问该网页。

我知道这是非常少的信息,但这听起来像是 url.com 的服务器端问题吗?我应该与管理员联系,还是这可能是我的事情?

也许我需要在我的 django 应用程序中配置我的 settings.py 的地址?

最佳答案

您可能想要运行它,以便它监听任何接口(interface)。来自 documentation :

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 or :: (with IPv6 enabled).



例如,您应该使用以下命令启动服务器python3.6 manage.py runserver 0.0.0.0:8000
一般来说,让这样的东西在网络上运行可能是不明智的,尤其是在调试的情况下。从相同的文档链接:

DO NOT USE THIS SERVER IN A PRODUCTION SETTING. It has not gone through security audits or performance tests. (And that’s how it’s gonna stay. We’re in the business of making Web frameworks, not Web servers, so improving this server to be able to handle a production environment is outside the scope of Django.)

关于django - 无法访问我通过 ssh 连接到的服务器上的开发服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55052562/

相关文章:

python - Firefox 没有收到 django csrf_token

python - Docker 镜像错误 : "/bin/sh: 1: [python,: not found"

python - 使用 Boto3 回调,显示上传进度

shell - 关于 : extracting *. gz 文件并将原始文件移动到其他文件夹

linux - 为什么我的服务器总是在文件夹权限中自动更改?

python - 需要从模板中的django获取实例id

java - 存储实时 TestNG 数据

amazon-web-services - 有谁知道如何减少 AWS 上的数据传出费用?

linux - BZIP2 压缩文件滞后

centos - laravel - 无法在服务器上打开 paths.php