[PYTHON] What to do when "Invalid HTTP_HOST header" appears in Django
Event
Invalid HTTP_HOST header: '*.*.*.*:8000'. You may need to add '*.*.*.*' to ALLOWED_HOSTS.
error contents
- The received site name and the site name set in Django are different.
Cause
settings.py
ALLOWED_HOSTS = []
Countermeasure ①
- Set an asterisk (*).
- Used for verification because it is not desirable in terms of security.
settings.py
ALLOWED_HOSTS = ['*']
Countermeasure ②
- Specify the FQDN of the site to publish.
- This is desirable if the site name such as the production site has been decided.
settings.py
ALLOWED_HOSTS = ['www.example.com']
Official documentation