在Django上移动域:“错误:无法分配该IP地址 - ”

时间:2015-06-18 10:24:51

标签: python django

我在Debian机器上运行Django 1.8。我之前在古老的域名上使用Gunicorn运行该站点。现在我正在尝试将其移动到新域。

我更新了Django设置文件中的ALLOWED_HOSTS设置,添加了新域并删除了旧域。我已经使用supervisord重新启动了Gunicorn。但是,该网站已关闭(CloudFlare的521错误页面)。

Gunicorn日志中没有错误,所以我开始调试过程,确保我可以运行Django应用程序。

当我尝试使用域运行runserver时,我看到了以下错误:

$ python manage.py runserver example-new.com:8000
Performing system checks...
System check identified no issues (0 silenced).
June 18, 2015 - 11:14:57
Django version 1.7.7, using settings 'example.settings.local'
Starting development server at http://example-new.net:8000/
Quit the server with CONTROL-C.
Error: That IP address can't be assigned-to.

但是,当我尝试使用域运行它时,它仍然有效,奇怪的是:

$ python manage.py runserver example-old.com:8000
Performing system checks...
System check identified no issues (0 silenced).
June 18, 2015 - 11:16:32
Django version 1.8, using settings 'example.settings.local'
Starting development server at http://example-old.com:8000/
Quit the server with CONTROL-C.

我发现这很奇怪,因为我确定/example/settings/local.py是最新的,我的其他设置文件也是如此。

除了ALLOWED_HOSTS之外,我还需要更新其他内容吗?或者我是否需要让Django以某种方式发现更新的设置?

1 个答案:

答案 0 :(得分:-1)

这是因为您使用的是旧版本。我遇到了同样的问题,更新了,一切正常!