5

I was going through the documentation for Django's ALLOWED_HOSTS here

I came across a string ['localhost', '127.0.0.1', '[::1]'] in the ALLOWED_HOSTS.

Everything looks fine except the '[::1]' part.

I can't find a realtime scenario where '[::1]' is used.

Can someone please explain in which use case we will use this [::1]

Underoos
  • 4,708
  • 8
  • 42
  • 85

3 Answers3

11

[::1] is the loopback address in ipv6, the equivalent would be 127.0.0.1 in ipv4.

M. Chris
  • 907
  • 1
  • 7
  • 5
1

I know ::1 is normally used for IPv6 as localhost

Roknix
  • 11
  • 3
0

That's most important part of settings - change ALLOWED HOSTS when you install your project to server. The settings there must be the same as in server configuration (e.g. nginx/gunicorn), but different for debug stage on local machine.

Advice: put all crucial settings like ALLOWED HOSTS in another one file in terms of security.

But while you're debugging-developing on local machine - you don't really need to change ALLOWED HOSTS.

PirrenCode
  • 444
  • 4
  • 14