报错代码
在网页上出现的报错信息
DisallowedHost at /
Invalid HTTP_HOST header: '192.168.102.2:8000'. You may need to add '192.168.102.2' to ALLOWED_HOSTS.
Request Method: GET
Request URL: http://192.168.102.2:8000/
Django Version: 1.11.6
Exception Type: DisallowedHost
Exception Value:
Invalid HTTP_HOST header: '192.168.102.2:8000'. You may need to add '192.168.102.2' to ALLOWED_HOSTS.
Exception Location: /root/project/django_env/lib64/python3.6/site-packages/django/http/request.py in get_host, line 113
Python Executable: /root/project/django_env/bin/python
Python Version: 3.6.8
Python Path:
['/root/project/mysite',
'/usr/lib64/python36.zip',
'/usr/lib64/python3.6',
'/usr/lib64/python3.6/lib-dynload',
'/root/project/django_env/lib64/python3.6/site-packages',
'/root/project/django_env/lib/python3.6/site-packages']
Server time: Thu, 27 Feb 2020 06:08:45 +0000
解决方法
(django_env) [root@python mysite]# vi mysite/settings.py
将以下内容:
......
ALLOWED_HOSTS = []
......
修改为:
......
ALLOWED_HOSTS = ['*']
......