jemson@home:~$

Django ALLOWED_HOSTS Limitation

Ran into an issue today that took quite a long time to get to the bottom of. That issue was that the ALLOWED_HOSTS parameter in Django doesn’t accept records containing and underscore (_).

After some further reading found that the reason behind this is that _ isn’t a valid character in domain names, so is excluded from being used in ALLOWED_HOSTS. In my case it was being used as part of a docker container name, so that nginx could source the django container by name/alias easily.

Apparently you can modify the regex usage in Django to get around this, but that seemed like a bit of a cludge method to me, so I renamed the containers to use hyphen (-) instead of underscore (_).

Figured this was worthy of note :)