Reputation: 3390
I am running a RoR app on my local. I have some translations in my hosts file.
127.0.0.1 localhost
127.0.0.1 example.dev
127.0.0.1 www.example.dev
127.0.0.1 api.example.dev
They were working fine, until I updated my OS to 10.11.4. If I send ping
request to www.example.dev
, it seems to work fine. The IP it translates to is 127.0.0.1
.
But when I visit www.example.dev
in my web browser, it seems to ignore hosts file and ping DNS server for IP.
I am not sure how, but going to localhost
in browser does translate to 127.0.0.1
.
Upvotes: 3
Views: 6099
Reputation: 2889
The host you are overriding is resolving via IPV6.
::1 is the loopback address for IPV6 which is analogous to 127.0.0.1 in IPV4. Add the following entries as the last lines in your /etc/hosts file.
::1 localhost
::1 www.example.dev
Upvotes: 0
Reputation: 403
I came across this while searching for an answer to a similar problem and wanted to post my findings for anyone else in the same position.
As a team of three, we found that edits to my /etc/hosts file appeared to work, while editing the other two's host files seemingly did not. Upon further digging, we realized I was on OS X 10.10, while they were on newer versions.
We found, after trying about a million things, that additions to the hosts file in 10.11 and up apparently could not have more than one space between the IP and the domain, for example:
DID NOT WORK:
1.2.3.4 some.site.com
DID WORK:
1.2.3.4 some.site.com
After making this change, we immediately started seeing expected results without any cache clears, reboots, or otherwise.
Upvotes: 5
Reputation: 524
Dont know why but ive disabled my lookback adapter and ipv6 and now its working.
so in your host file disable these two items
# ::1 localhost
# fe80::1%lo0 localhost
Some fubar osx bug... I miss steve....
Upvotes: 8