Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Django Basics What a View! Running the Server

Herman Brummer
Herman Brummer
6,414 Points

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

I updated the settings.py file with:

ALLOWED_HOSTS = [0.0.0.0]

But that does not work and now only get:

"0.0.0.0 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.

#settings.py

#make sure you have quotes
ALLOWED_HOSTS = ["0.0.0.0"]

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.