django报错解决:Invalid HTTP_HOST header: 'xxx.com'. You may need to add u'xxx.com' to ALLOWED_HOSTS.

时间:2022-09-16 22:15:08

django版本:1.11.15

使用uwsgi+nginx运行django程序,出现报错,报错为:
Invalid HTTP_HOST header: 'xxx.com:82'. You may need to add u'xxx.com' to ALLOWED_HOSTS.
xxx.com为绑定的测试域名,82为端口

解决办法:
修改项目的setting.py配置文件


ALLOWED_HOSTS = []
改为
ALLOWED_HOSTS = ['*']

再次运行可以成功访问了。