Issue
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
I read the documentation about IPV6 and got some answers, you must put IPV6 in square brackets.
Localhost for IPV6: ::1
Any address for IPV6 : ::
(for IPV4 is 0.0.0.0
)
So in settings.py AllOWED_HOSTS should be ['my_IPV4', '[my_IPV6]', 'localhost']
Django run server command: python manage.py runserver [::]:8000
To access the IPV6 address with port using https://[IPV6 address]:8000
You will need brackets for URL to access IPV6 address even without port number
http://[fe80::b746:6473:e65f:5dd4]/foo/bar
http://[fe80::b746:6473:e65f:5dd4]:8000/foo/bar
Reference https://cheat.readthedocs.io/en/latest/ipv6.html
Answered By - Qixin
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.