[Solved]-Invalid HTTP_HOST header: '0.0.0.0:8000'. You may need to add '0.0.0.0' to ALLOWED_HOSTS

15👍

I just added the ip in ALLOWED_HOSTS property in the file <your_app_path>/settings.py.

e.g.

...
ALLOWED_HOSTS = ['0.0.0.0']
...

And it worked fine.

5👍

Take a look at settings.py and fill the ALLOWED_HOSTS as follows.
For local host:

ALLOWED_HOSTS = ["0.0.0.0"]

OR you can do

ALLOWED_HOSTS = ["*"]

3👍

in settings.py,
change
ALLOWED_HOSTS = ['*']
this work for me,
*represent the all the ports can have access to the site

1👍

ALLOWED_HOSTS = os.environ.get('DJANGO_ALLOWED_HOSTS', '*').split()

I’m just added split() because without split() it just localhost 127.0.0.1 0.0.0.0 [::1] for django need the list.

0👍

You have to find your device ip address from where you are running the django app.

How to find the local ip address

To use django on local network
Run command
python manage.py runserver 0.0.0.0:8000

To run on other device connected to same local network you have to type ip address of your server device from where you are running django app.

192.168.1.1:8000/ # this is just dummy example.

Its should work as far both devices are connected to same network. And firewall is allowed.

0👍

If you are using Docker you’ll have to rebuild your container.

Considering you have already added your host on your config file (ALLOWED_HOSTS = ['0.0.0.0']), you just have to run:

docker-compose down 

docker-compose build

docker-compose up

Leave a comment