'Django project cannot be accessed using IPV6 address

I am running my Django project on a ubuntu server. I have changed the allowed host in settings.py

ALLOWED_HOSTS = ['my_IPV4', 'my_IPV6', 'localhost']

I allowed access to port 8000 by sudo ufw allow 8000.

I run the server by python manage.py runserver 0.0.0.0:8000 however I can only access the IPV4 address but the IPV6 address on port 8000 is not reachable. My IPV6 address is active but port 8000 seems not working. Did I miss something on configuring IPV6?



Solution 1:[1]

Add "[::1]" in Allowed host setting, then run :

python manage.py runserver --ipv6 "[::1]:8000"

Reference: https://docs.djangoproject.com/en/4.0/ref/settings/#allowed-hosts

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 rs_punia