Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Django Basics What a View! Running the Server

Herman Brummer
Herman Brummer
6,414 Points

ERROR: Invalid HTTP_HOST header: ''. You may need to add '' to ALLOWED_HOSTS.

I updated the settings.py file with:


But that does not work and now only get:

" refused to connect. Search Google for 8000 ERR_CONNECTION_REFUSED"

Paul Kamarudin
Paul Kamarudin
5,292 Points

Are you using workspace or a local version on your laptop?

If on your laptop, what version of Django are you using? Have you got DEBUG set to TRUE or FALSE?

Let me know and we can walk thru.

4 Answers

Lucas Diz
Lucas Diz
4,804 Points

Probably dont need to put the numbers after the runserver command. So, inside the learning_site directory write on your terminal:

python3 manage.py runserver

This should work just fine.


#make sure you have quotes

I tried this, but then got another error: ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?

Turned out, since I was working in a virtual environment, I had to install Django again.