测试环境:

[root@nanx-lli ~]# lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.4.1708 (Core)
Release: 7.4.1708
Codename: Core

[root@nanx-lli ~]# python
Python 2.7.5 (default, Aug 4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(1, 11, 12, u'final', 0)

[root@nanx-lli HelloWorld]# pwd
/root/HelloWorld/HelloWorld
[root@nanx-lli HelloWorld]# tree
.
├── __init__.py
├── __init__.pyc
├── settings.py
├── settings.pyc
├── urls.py
├── urls.pyc
├── view.py
├── view.pyc
├── wsgi.py
└── wsgi.pyc

0 directories, 10 files
[root@nanx-lli HelloWorld]# cat view.py

from django.http import HttpResponse

def hello(request):
return HttpResponse("Hello world!")

问题:

PC: 10.245.36.203上通过chrome访问,http://10.245.242.221:8000时报错,并且此时在Linux上同时有错误log显示:

Invalid HTTP_HOST header: '10.245.242.221:8000'. You may need to add u'10.245.242.221' to ALLOWED_HOSTS.

解决方案:

添加10.245.242.221到allowed_hosts.

修改setting.py

......

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ['10.245.242.221']

# Application definition

......

django error: DisallowedHost: Invalid HTTP_HOST header: ''. You may need to add u'' to ALLOWED_HOST的更多相关文章

  1. 运行django项目出现Invalid HTTP_HOST header: '192.168.1.111:8000'. You may need to add '192.168.1.111' to ALLOWED_HOSTS

    Request Method: GET Request URL: http://202.201.38.70:8000/angular Django Version: 1.11.3 Exception ...

  2. Django运行访问项目出现的问题:DisallowedHost at / Invalid HTTP_HOST header

    Django运行访问项目出现的问题:DisallowedHost at / Invalid HTTP_HOST header: DisallowedHost at / Invalid HTTP_HOS ...

  3. 访问Django项目出现DisallowedHost at / Invalid HTTP_HOST header问题

    闲来无事,想玩玩django,源码安装碰到了一堆乱七八糟依赖性问题,耗费一下午的时间总算是在ubuntu14.04上搭建好了python3+django2开发环境, 心血来潮,创建了一个django项 ...

  4. Django运行项目时候出现DisallowedHost at / Invalid HTTP_HOST header:

    web端错误现象: DisallowedHost at / Invalid HTTP_HOST header: 'ip:8000'. You may need to add u'ip' to ALLO ...

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

    django版本:1.11.15 使用uwsgi+nginx运行django程序,出现报错,报错为:Invalid HTTP_HOST header: 'xxx.com:82'. You may ne ...

  6. Django运行访问项目出现的问题:Invalid HTTP_HOST header: '192.168.114.25:8001'. You may need to add u'192.168.114.25' to ALLOWED_HOSTS.

    当运行python manage.py runserver 0.0.0.0:8001时候,出现Invalid HTTP_HOST header: '192.168.114.25:8001'. You ...

  7. Invalid HTTP_HOST header: 'xxx.xxx:8000'. You may need to add 'xxx.xx' to ALLOWED_HOSTS

    用python3 manage.py runserver 0.0.0.0:8000命令运行django程序后,通过浏览器访问服务器网址的8000端口,出现访问错误,报错为 Invalid HTTP_H ...

  8. 配置python+mod_wsgi+apache 时 在浏览器中访问服务器时报错:Invalid HTTP_HOST header: 'XXXXX'. You may need to add u'XXXXX' to ALLOWED_HOSTS,在setting.py中添加‘*”无效的原因

    配置python+mod_wsgi+apache 时 在浏览器中访问服务器时报错:Invalid HTTP_HOST header: 'XXXXX'. You may need to add u'XX ...

  9. Invalid HTTP_HOST header: 'xxx.xx.xxx.xxx:8000'. You may need to add 'xxx.xx' to ALLOWED_HOSTS

    Invalid HTTP_HOST header: 'xxx.xx.xxx.xxx:8000'. You may need to add 'xxx.xx' to ALLOWED_HOSTS - buk ...

随机推荐

  1. [JSON].connectionValue()

    语法: [JSON].connectionValue() 说明: 将对象的所有键值接连成新的字符串值 返回: [String] 示例: Set a = toJson() c = Array(1,2,3 ...

  2. 孤荷凌寒自学python第七十七天开始写Python的第一个爬虫7

    孤荷凌寒自学python第七十七天开始写Python的第一个爬虫7 (完整学习过程屏幕记录视频地址在文末) 今天在上一天的基础上继续完成对我的第一个代码程序的书写. 今天的学习仍然是在纯粹对docx模 ...

  3. Python最长连续数列的O(n)解法

    题目 输入一个乱序的连续数列,输出其中最长连续数列长度,要求算法复杂度为 O(n) . 输入样例 100,4,200,1,3,2 54,55,300,12 1 5,4,3,2,1 1,2,3,4,5, ...

  4. Halcon和visionPro的比较

    很多朋友会问到visionpro和halcon这两款机器视觉软件,到底学哪个好呢,今天重码网就给大家讲一讲: 首先比较下两者的优缺点: halcon: 提供的图像算法要比Visionpro多,也就是说 ...

  5. (转载)IE8+兼容经验小结

    本文分享下我在项目中积累的IE8+兼容性问题的解决方法.根据我的实践经验,如果你在写HTML/CSS时候是按照W3C推荐的方式写的,然后下面的几点都关注过,那么基本上很大一部分IE8+兼容性问题都OK ...

  6. jquery datatable 常用例子

    在项目中经常用到DataTable,如果DataTable使用得当,不仅能使程序简洁实用,而且能够提高性能,达到事半功倍的效果,现对DataTable的使用技巧进行一下总结. 一.DataTable简 ...

  7. UESTC 1717 Journey(DFS+LCA)(Sichuan State Programming Contest 2012)

    Description Bob has traveled to byteland, he find the N cities in byteland formed a tree structure, ...

  8. JS中Document节点总结

    document对象是documentHTML的一个实例,也是window对象的一个属性,因此可以将document对象作为一个全局对象来访问. Document节点的子节点可以是DocumentTy ...

  9. eg_3

    3. 编写一个程序,返回一个 double 类型的二维数组,数组中的元素通过解析字符串参数获得,如字符串参数:“1,2;3,4,5;6,7,8”,则对应的数组为: d[0][0]=1.0, d[0][ ...

  10. ACM 第十二天

    博弈论(巴什博奕,威佐夫博弈,尼姆博弈,斐波那契博弈,SG函数,SG定理) 一.  巴什博奕(Bash Game): A和B一块报数,每人每次报最少1个,最多报4个,看谁先报到30.这应该是最古老的关 ...