当前位置:   article > 正文

指定Django工程的IP和端口后项目运行没有出问题,但是无法访问端口且报错:Invalid HTTP_HOST header: '192.168.0.102:9999'. You may need_invalid http host: 172.16.121.122:9200/

invalid http host: 172.16.121.122:9200/

cmd中报错内容为:

  1. D:\resp_work\py_1707A\days02\mysite>python manage.py runserver 192.168.0.102:9999
  2. Performing system checks...
  3. System check identified no issues (0 silenced).
  4. You have 13 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
  5. Run 'python manage.py migrate' to apply them.
  6. May 02, 2020 - 17:49:19
  7. Django version 1.11.6, using settings 'mysite.settings'
  8. Starting development server at http://192.168.0.102:9999/
  9. Quit the server with CTRL-BREAK.
  10. Invalid HTTP_HOST header: '192.168.0.102:9999'. You may need to add '192.168.0.102' to ALLOWED_HOSTS.
  11. [02/May/2020 17:49:29] "GET / HTTP/1.1" 400 62276
  12. Invalid HTTP_HOST header: '192.168.0.102:9999'. You may need to add '192.168.0.102' to ALLOWED_HOSTS.
  13. [02/May/2020 17:49:29] "GET /favicon.ico HTTP/1.1" 400 62200
  14. Invalid HTTP_HOST header: '192.168.0.102:9999'. You may need to add '192.168.0.102' to ALLOWED_HOSTS.
  15. [02/May/2020 17:49:49] "GET / HTTP/1.1" 400 62276
  16. Invalid HTTP_HOST header: '192.168.0.102:9999'. You may need to add '192.168.0.102' to ALLOWED_HOSTS.
  17. [02/May/2020 17:49:50] "GET /favicon.ico HTTP/1.1" 400 62200

报错原因是:我们的Django工程并没有打开192.168.0.102端口,所以需要打开

解决方案是:

在我们创建的项目里修改setting.py文件

ALLOWED_HOSTS = ['*']  #在这里请求的host添加了*

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/170833
推荐阅读
相关标签
  

闽ICP备14008679号