gpt4 book ai didi

python - 您可能需要将 u'127.0.0.1' 添加到 ALLOWED_HOSTS

转载 作者:行者123 更新时间:2023-12-03 17:15:57 24 4
gpt4 key购买 nike

尝试启动 Django 服务器时出现以下错误

python  manage.py runserver 0.0.0.0:8000

Performing system checks...

System check identified no issues (0 silenced).
August 18, 2019 - 20:47:09
Django version 1.11, using settings 'config.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
Invalid HTTP_HOST header: '127.0.0.1:8000'. You may need to add u'127.0.0.1' to ALLOWED_HOSTS.
Invalid HTTP_HOST header: '127.0.0.1:8000'. You may need to add u'127.0.0.1' to ALLOWED_HOSTS.
Invalid HTTP_HOST header: '127.0.0.1:8000'. You may need to add u'127.0.0.1' to ALLOWED_HOSTS.
Invalid HTTP_HOST header: '127.0.0.1:8000'. You may need to add u'127.0.0.1' to ALLOWED_HOSTS.
Invalid HTTP_HOST header: '127.0.0.1:8000'. You may need to add u'127.0.0.1' to ALLOWED_HOSTS.
Invalid HTTP_HOST header: '127.0.0.1:8000'. You may need to add u'127.0.0.1' to ALLOWED_HOSTS.
[18/Aug/2019 20:47:09] "GET /view/stockprice/ HTTP/1.1" 400 16918
[18/Aug/2019 20:47:09] "GET /view/stockprice/ HTTP/1.1" 400 16918
[18/Aug/2019 20:47:09] "GET /view/stockprice/ HTTP/1.1" 400 16918
Invalid HTTP_HOST header: '127.0.0.1:8000'. You may need to add u'127.0.0.1' to ALLOWED_HOSTS.

我已经在 ALLOWED_HOST 列表中给出了 127.0.0.1。
SECRET_KEY=BeatTheStreet

DEBUG=True

ALLOWED_HOSTS=['127.0.0.1', '0.0.0.0']

EVENT_STARTED=True
EVENT_ENDED=

# Production database details
DB_NAME=
DB_USER=
DB_PASSWORD=
DB_HOST=
DB_PORT=

解决此问题的指针将非常有帮助。

由于我在 Django app not opening from different machine 中遇到的问题,我正在使用 0.0.0.0:8000 运行服务器

最佳答案

发生这种情况只是因为 localhost您的主机不是您的主机服务器的本地主机。你可以这样做

ALLOWED_HOSTS=['<your host ip address>',]

或者
ALLOWED_HOSTS=['*',]

虽然不推荐通配符,但在开发模式下很有用。

enter image description here
在给定的 ifconfig 中,inet 地址 192.168.1.104是你主机的ip,如果运行 ifconfig在主机

关于python - 您可能需要将 u'127.0.0.1' 添加到 ALLOWED_HOSTS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57545934/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com