测试环境:

[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. lintcode491 回文数

    回文数 判断一个正整数是不是回文数. 回文数的定义是,将这个数反转之后,得到的数仍然是同一个数. 注意事项 给的数一定保证是32位正整数,但是反转之后的数就未必了. 您在真实的面试中是否遇到过这个题? ...

  2. 关于excle导数据的一些代码笔记

    package com.bonc.util; import java.io.File; import java.io.FileInputStream; import java.io.FileOutpu ...

  3. react创建新项目并且修改配置文件

    react创建项目 这是我在用react搭建项目时,用到的一些东西,顺序纯属自己定义, 一.创建项目 用react 创建一个项目,这也是官方给出的 1.npm install create-react ...

  4. SGU 176 Flow construction(有源汇上下界最小流)

    Description 176. Flow construction time limit per test: 1 sec. memory limit per test: 4096 KB input: ...

  5. 关于14道魔鬼js考题的整理

    1.(function(){ return typeof arguments })(); 这里返回时是argument类型,它是个类数组,也就对象,所以是object,准确谁是[object argu ...

  6. 视频播放截图及简要文字介绍——Thunder团队

    视频播放截图及简要文字介绍 图一:团队Logo ——从此我们有了自己的标志 图二:扫描本地书籍 ——可阅读本地的喜爱书籍 图三:在本地添加自己喜爱的图书 ——将自己喜爱的书籍加入书架,方便阅读 图四: ...

  7. Android 开发错误集锦

    1. eclipse的Device中不显示手机 在eclipse中连接不上手机,出现adb server didn't ACK  fail to start daemon 错误. 出现这种原因是因为a ...

  8. oracle数据库之PL/SQL 流程控制语句

    介绍 PL/SQL 的流程控制语句, 包括如下三类: 1.控制语句: IF 语句 2.循环语句: LOOP 语句, EXIT 语句 3.顺序语句: GOTO 语句, NULL 语句 一 条件语句 IF ...

  9. HDU2376Average distance(树形dp|树上任意两点距离和的平均值)

    思路: 引:如果暴力枚举两点再求距离是显然会超时的.转换一下思路,我们可以对每条边,求所有可能的路径经过此边的次数:设这条边两端的点数分别为A和B,那 么这条边被经过的次数就是A*B,它对总的距离和的 ...

  10. .net 简体转换繁体实例,繁体转换简体 Encode.dll、下载

    在项目中先引用Encode.dll  下面是下载地址: Encode.dll ChineseConverter.dll 1.html页面代码 <%@ Page Language="C# ...