Whats the difference between 127.0.0.1 and ::1

2.8k views Asked by At

For couple day I was fighting to set up apache installed from Homebrew on OSX 10.10 . For some reason everything was working but not the local domains that I was trying to setup via hosts file. No matter what I was doing only http://localhost was available trough browser. And then I've changed one thing.

Originally in /etc/hosts I was putting this line to set local domain:

127.0.0.1  imac.dev

And that did not work, but then I changed it to:

::1  imac.dev

which is how localhost was set up in hosts files and it works!

Can anyone explain me why?

1

There are 1 answers

2
Panama Jack On BEST ANSWER

The first one is an IPv4 address and the other signifies and IPv6 local address.

Loopback address for ipv4

 127.0.0.1  imac.dev

Loopback local address for ipv6

::1  imac.dev

In most current OSes IPv6 if enabled, takes precedence over ipv4 so that might be the reason you were having that issue. Similarly I, had to use IPv6 IP address in my DNS record for SPF because GMail was looking for that too. So whether we like it or not, it's being favored and will replace IPv4 eventually.

https://en.wikipedia.org/wiki/Localhost