Django错误 DisallowedHost at / Invalid HTTP_HOST header. You may need to add to ALLOWED_HOSTS.

创建好了Django,但是出现以下错误。
Django错误 DisallowedHost at / Invalid HTTP_HOST header. You may need to add to ALLOWED_HOSTS._第1张图片

DisallowedHost at /
Invalid HTTP_HOST header: '101.201.155.148:8006'. You may need to add '101.201.155.148' to ALLOWED_HOSTS.
Request Method:	GET
Request URL:	http://101.201.155.148:8006/
Django Version:	3.1a1
Exception Type:	DisallowedHost
Exception Value:	
Invalid HTTP_HOST header: '101.201.155.148:8006'. You may need to add '101.201.155.148' to ALLOWED_HOSTS.
Exception Location:	/usr/local/lib/python3.6/dist-packages/Django-3.1a1-py3.6.egg/django/http/request.py, line 137, in get_host
Python Executable:	/usr/bin/python3
Python Version:	3.6.9
Python Path:	
['/root/Detection',
 '/usr/lib/python36.zip',
 '/usr/lib/python3.6',
 '/usr/lib/python3.6/lib-dynload',
 '/usr/local/lib/python3.6/dist-packages',
 '/usr/local/lib/python3.6/dist-packages/cloud_init-19.1.3-py3.6.egg',
 '/usr/local/lib/python3.6/dist-packages/Django-3.1a1-py3.6.egg',
 '/usr/local/lib/python3.6/dist-packages/sqlparse-0.3.1-py3.6.egg',
 '/usr/local/lib/python3.6/dist-packages/pytz-2020.1-py3.6.egg',
 '/usr/local/lib/python3.6/dist-packages/asgiref-3.2.7-py3.6.egg',
 '/usr/lib/python3/dist-packages']
Server time:	Wed, 17 Jun 2020 01:21:33 +0000

只需要修改settings.py文件中的允许所有站点访问就行了。
Django错误 DisallowedHost at / Invalid HTTP_HOST header. You may need to add to ALLOWED_HOSTS._第2张图片
Django错误 DisallowedHost at / Invalid HTTP_HOST header. You may need to add to ALLOWED_HOSTS._第3张图片
在这里插入图片描述

你可能感兴趣的:(Django)