Django 1.5 Invalid HTTP_HOST header (Posted on June 8th, 2013)

I recently updated all the components for my blog. Going to Django 1.5 caused an issue that I had never seen before so I wanted to share the quick way to fix:

SuspiciousOperation: Invalid HTTP_HOST header

If you see that error it is because your ALLOWED_HOSTS setting variable isn't set and you have debug set to False. For a site running on Heroku your ALLOWED_HOSTS should look something this:

ALLOWED_HOSTS = ["maxburstein.herokuapp.com", ".maxburstein.com"]

Having a . before my domain name will allow for any subdomains to be matched. Just a reminder this error will only show up when DEBUG is set to False so if you're running on Heroku be sure to do testing with Foreman.

Tags: Django, Heroku