![]() |
VOOZH | about |
Django is a full-stack Python framework for building websites. Sometimes, We might see a "DisallowedHost" error. This happens when the website’s address isn’t on a list of allowed addresses in your Django settings. Sometimes this error occurs when a proxy server tries to interact with our Django server for example gunicorn. In this article, we’ll go over how to fix this by changing the ALLOWED_HOSTS setting in Django.
The ALLOWED_HOSTS setting in Django is a list of the website addresses or domain names that your Django site is allowed to serve. If someone tries to visit your site using an address not on this list, Django will show a DisallowedHost error. To fix this, just add the correct domain name or IP address to the ALLOWED_HOSTS list in your Django project's settings file.
settings.py
4. Wildcard Subdomains: If you want to allow all subdomains of a specific domain, you can use a wildcard.
5. Save and Restart: After modifying the ALLOWED_HOSTS setting, save the changes and restart your Django server to apply the new configuration.
The DisallowedHost error in Django can be annoying, but it's simple to fix. Just add the host or domain name causing the error to the ALLOWED_HOSTS list in your settings. Don't forget to restart your Django server after making the change. This quick fix will help get your Django app working smoothly again.