8👍
✅
This happens just because localhost
of your host machine is not localhost of your host server. You can either do
ALLOWED_HOSTS=['<your host ip address>',]
or
ALLOWED_HOSTS=['*',]
although wildcard is not recommended, but useful in dev mode.
in the given ifconfig, the inet addr 192.168.1.104
is the ip of your host machine, if run ifconfig
in the host
1👍
If after adding ‘*’ it still doesn’t work, you have to find ‘request.py’ file in venv and add your host by yourself: allowed_hosts = "your host"
- Invalid HTTP_HOST header: The domain name provided is not valid — requests to dockerized django app using container name
- How to Hash Django user password in Django Rest Framework?
1👍
My solution, my env file template with comments, in settings.py should be as shown in commented examples
# ENV file template,
# Install: pip install python-decouple
# Your Django app secret key without '' or " ", in Django settings.py should be as follow:
# SECRET_KEY = config('SECRET_KEY')
SECRET_KEY=secret-key
# Debug state, in Django settings.py should be as follow:
# DEBUG = config('DEBUG')
DEBUG=1
# Allowed Hosts in Django settings.py should be as follow:
# ALLOWED_HOSTS = [config('ALLOWED_HOST_1'),config('ALLOWED_HOST_2'),config('ALLOWED_HOST_3')]
ALLOWED_HOST_1=127.0.0.1
ALLOWED_HOST_2=192.168.99.100
ALLOWED_HOST_3=localhost
## Settings for Docker SQL postgress, dont use " "
SQL_ENGINE=django.db.backends.postgresql
SQL_DATABASE=api_db
SQL_USER=api-api-user
SQL_PASSWORD=api-pass
SQL_HOST=db
SQL_PORT=5432
## In Django settings.py should be as follow:
# DATABASES = {
# "default": {
# "ENGINE": config('SQL_ENGINE'),
# "NAME": config('SQL_DATABASE'),
# "USER": config('SQL_USER'),
# "PASSWORD": config('SQL_PASSWORD'),
# "HOST": config('SQL_HOST'),
# "PORT": config('SQL_PORT'),
# }
# }
- Django.db.utils.OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")
- Passing values to constructor of custom HTMLElement
- How to make TimeField timezone-aware?
- Django Url, Slug for Detail Page
- Docker, web app static files. Best practices?
- Django templates – using block.super in included template fails (exception)
Source:stackexchange.com