1

In my hosts file I have:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost 
fe80::1%lo0 localhost
127.0.0.1 home.dev
fe80::1%lo0 home.dev

Yet, when I go to home.dev, I get the Google search page, and when I go to http://home.dev, I get a blank page. How do I get it to actually go to the index page that says "It works!" (I have index.php in the root directory of /Library/WebServer/Documents with just that).

In System Preferences for Networks, DNS, I have "192.168.1.1" and "home" which are greyed out. If I try to use "+" to add 127.0.0.1, the previous entry gets wiped out.

/Network/Advanced/DNS tab

How do I get this working properly? I've tried different solutions over the years but never got this to work properly. I'm using 10.8 but will be upgrading to Yosemite after it comes out.

  • Does 127.0.0.1 get the 'It works!' page? – grg Aug 24 '14 at 12:16
  • Yes, 127.0.0.1 gets to the "It works!" page. – lolajl Aug 24 '14 at 22:18
1

You could try to connect to http://home.dev./ (note the single dot at the end of the URL; also, when typing the URL, make sure to type the http:// part into your browser address field too). The reason you're not getting luck is with the somewhat irritating web browser behaviour, which is to try to add some common words to the server address part of the URL if it doesn't look "normal" (i.e. you'll notice quite often the browser try to be smart and add www or .com to the beginning or the end of the server address in your URL).

The DNS settings window, screenshot of which you attached, is used to configure DNS servers rather than static host to IP mappings like you do in /etc/hosts. When you add 127.0.0.1 entry, all you're doing is telling the system to ignore the DNS settings and the search domain it acquired via DHCP and instead use 127.0.0.1 as the DNS server - i.e. the system will try to send DNS queries to 127.0.0.1 expecting a DNS service to run there and respond to those. The default entries are greyed out to indicate they were put there automatically for you by the DHCP client.

One way to see what the system resolver is trying to do, bypassing the nonsense of the browser trying to be too smart behaviour, is to open the Terminal.app and type ping home.dev in there and see if you get any responses, and which IP address they come back from. If that works, it means that the resolver is working fine and that the issue is with your browser.

  • Connecting to home.dev. results: Safari - blank page Chrome - "It works!" page (index.php) when I type in ping home.dev I get: 'PING home.dev (127.0.0.1): 56 data bytes 64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.050 ms 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.252 ms ' – lolajl Aug 24 '14 at 22:16
  • OK, try to clear the cache in Safari for that host, to make sure it really tries to connect there and not just showing you the local copy of the page. In Safari, go into Safari / Preferences, choose Privacy tab, and wait until you see Details... button to the right and below of Remove All Website Data.... Click the Details button and type both 127.0.0.1 as well as home.dev in the search box, and remove all entries you can see there in the list for these two hosts. Then try again connecting with Safari and see how it works. – mike Aug 25 '14 at 22:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .