Last modified: Jan 10, 2023 By Alexander Williams
How to Solve DisallowedHost at / Django
in this post, we'll learn how to solve DisallowedHost at / in Django.
In local host
If your app in the localhost, you need to add "localhost" or "127.0.0.1" to ALLOWED_HOSTS in settings.py.
ALLOWED_HOSTS = ['localhost'] #if you use localhost as url
ALLOWED_HOSTS = ['127.0.0.1'] #if you use 127.0.0.1 as url
If you want to allow each host you need to add '*' to ALLOWED_HOSTS.
ALLOWED_HOSTS = ['*']
if your app in production, you need to add the domain name to ALLOWED_HOSTS
ALLOWED_HOSTS = ['domain_name.com']
So, in this article, we've learned how to solve DisallowedHost at/in Django.
if your app in production, you should only set domain name in ALLOWED_HOSTS