Answer the question
In order to leave comments, you need to log in
How to make DisallowedHost error 400 instead of 500 in Django?
In Django 1.8, the DisallowedHost error should already return a 400 error instead of a 500 error. However, my mailbox is still full of such letters every day -
DisallowedHost: Invalid HTTP_HOST header: 'www.cirk.irk.ru'. You may need to add u'www.cirk.irk.ru' to ALLOWED_HOSTS.
The error is caused by GoogleBot. Logging is configured like this:
'django.security.DisallowedHost': {
'handlers': ['null'],
'propagate': False,
},
Answer the question
In order to leave comments, you need to log in
Try to make a 301 ("permanent") redirect from www.cirk.irk.ru to cirk.irk.ru using nginx. In theory, this should discourage Googlebot. In addition, you will definitely stop receiving such emails, because requests for a non-existent domain will not reach Django.
It's written
You may need to add u'www.cirk.irk.ru' to ALLOWED_HOSTS
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question