ALLOWED_HOSTS in settings.py

This is going to be a short post. It deals with a specific issue I just ran into.

I had an old project that I had started. I made the decision to start up development on it again. The project was running Django 1.4.3. There were some sites I had done in 1.5, but I had not migrated a site yet. I jumped into my requirements.txt and changed the line to 1.5.2 the most current stable version of Django.

The migration was not too difficult and I decide to push it to Heroku. After pip installs the updated version of Django I load up the app and I get a 500 status code. I double check my local version and I don’t get the error. I push out a change to make Heroku run DEBUG=True (running the local as DEBUG=False would have been too easy). The site works.

I had not setup any logging as there was not much code, so I setup a quick log to console. I notice that it is complaining about the ALLOWED_HOSTS setting.

Django released a security update in February 2013 for 1.4.4 (just missed it) that requires the ALLOWED_HOSTS to be set if DEBUG=False. All you have to do is set it to your FQDN. I went ahead and set it for my local development site and Heroku.

Hopefully this will save someone some time.


Enjoyed the article?

Then I guarantee that you will find my video series useful and enjoyable. The course focuses on taking someone completely new to Node.js and giving them a great foundation to start building real applications. The course is named The Complete Guide to Node.js.

Feel comfortable with Node.js and want to build web applications? Then you will find my other video series useful. It is named Building Complex Express Sites with Redis and Socket.io

I also have a book! It covers Node.js, Express, Passport, Socket.IO, Redis, RabbitMQ, React, Backbone, Grunt, and Ansible. All in one book! It is called Building Scalable Apps with Redis and Node.js.

Receive tips on Node.js, Python, and more