Lion Hosts file bug/issue

  • Posted on: 21 December 2011
  • By: Pradeep George

If you are working with website development or want to block or redirect access to specific domains, you have probably edited the system file /etc/hosts like me. I have recemtly upgraded to Lion and to my astonishment, I found that the entries in the hosts file is anymore considered. After a lot of checking around, this is what worked for me.

1. If you don't have the program TextWrangler (Free text editor for Mac), go ahead and install it.

2. Launch Terminal (Go to Applications>>Utilities)

3. in the terminal type  sudo edit /private/etc/hosts

4.Enter your password

5. This will launch Textwrangler with the content of the hosts file

6. Ensure that you are having the following format in your hosts file, otherwise you can copy the code shown below and past it there.

##
# 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

## localhost ip4
127.0.0.1 first.localhost
127.0.0.1 second.localhost
127.0.0.1 third.localhost

## localhost ip6
::1 localhost
fe80::1%lo0 localhost
#

7. Go through each of the line and check whether each line is showing Unix (LF) as shown in the below picture and save it.

8. Go to terminal and type  ping first.localhost , If you are getting a response as shown below, then it is working fine.

Good luck!!

Category: 

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Refresh Type the characters you see in this picture. Type the characters you see in the picture; if you can't read them, submit the form and a new image will be generated. Not case sensitive.  Switch to audio verification.