109👍
Add the ALLOWED_HOSTS setting to your settings.py like so…
ALLOWED_HOSTS = [
'.example.com', # Allow domain and subdomains
'.example.com.', # Also allow FQDN and subdomains
]
I had this same problem and found the answer here in the docs
update: django 1.6 docs are no longer online, I updated the link to go to the django 1.7 docs for ALLOWED_HOSTS
setting.
9👍
If you’ve definitely set ALOWED_HOSTS
– make sure your hostname doesn’t contain underscores. It’s technically illegal.
I had to print out various functions and it boiled down to this regex failing to detect a domain in django.http
host_validation_re = re.compile(r"^([a-z0-9.-]+|\[[a-f0-9]*:[a-f0-9:]+\])(:\d+)?$")
And indeed, my domain had an underscore in it.
- [Django]-DatabaseError: current transaction is aborted, commands ignored until end of transaction block?
- [Django]-Django model "doesn't declare an explicit app_label"
- [Django]-Cancel an already executing task with Celery?
1👍
This is not a solution, but for debugging purposes you might set the ALLOWED_HOSTS setting in your settings.py like this
ALLOWED_HOSTS = ['*']
It should definitely work. If not, at least you will know the problem isn’t Django denying access to the given url.
- [Django]-Ignoring Django Migrations in pyproject.toml file for Black formatter
- [Django]-Default filter in Django admin
- [Django]-Passing STATIC_URL to file javascript with django