The Core Dump

It updates the blog, or it gets the hose again

[By Nic Lindh on Friday, 30 September 2011]

Editing the hosts file in Mac OS X 10.7 Lion

If you’re trying to edit your hosts file in Lion, here’s why it’s not working and how to fix it.

I’m posting this in the hope it’ll save somebody else a few minutes of their time.

Apparently Apple has decided to Think Different about the hosts file in Mac OS X Lion. If you want to put in your own entries, they will be politely ignored unless you put them first in the file.

Editing the hosts file allows you to do useful things like preview a site on a production server before flipping the switch on the DNS so you can suss out any errors before the world sees the site, or to access the backend of a CMS on an origin server for updates when the live site is cached by something like Akamai.

To illustrate, here’s the original Mac OS X hosts file, located at /etc/hosts:

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

If you were to do the standard UNIX thing of appending your own changes at the bottom—which is what you would do if you’ve spent any time around UNIX machines—you’d end up with something like:

\## \# 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 192.168.1.15 thecoredump.org

But alas, this configuration will in fact not do anything.

The reason is that Apple has apparently decided you must put your own entries at the top. So you must do this instead:

192.168.1.15 thecoredump.org \## \# 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

I don’t know why this is. I wasn’t in that meeting. From my Googling around it seems nobody from the documentation team at Apple were in that meeting either.

So if you want to control your hosts file in Mac OS X Lion, you must put your own entries first and it will work like you expect.

You don’t have to flush the cache or anything. Soon as you save the configuration, it goes to work.

Hope this saves somebody on the Internet some time.

« Why I’m all-in on FiveFingers

 »


Enjoy the ten latest posts!

Everything that irritates us about others can lead us to an understanding of ourselves

How the G.O.P. Elite Lost Its Voters to Donald Trump (The New York Times)

Review: Synology DS416j

The DS416j is a nice NAS for light home use. Just don’t expect raw power.

Democracy is the theory that the common people know what they want and deserve to get it good and hard

Know what's weird? Day by day, nothing seems to change. But pretty soon, everything's different

Just because nobody complains doesn't mean all parachutes are perfect

Fueling Terror: How Extremists Are Made

Does Engineering Education Breed Terrorists?

(Nerd Note) Moving to GitHub Pages

The Core Dump is moving to GitHub Pages. This is a good thing, most likely.

Clash of Republican Con Artists (The New York Times)

Millions of ordinary Americans support Donald Trump. Here’s why (The Guardian)

Time traveling with Friends

Tempus fugit and all that.

The Voters Decide (Stratechery)

Hell is truth seen too late

The tire fire of democracy

Nic has never been more worried for the future of America.

The One Weird Trait That Predicts Whether You’re A Trump Supporter (Politico)

Vader’s Redemption

How America Made Donald Trump Unstoppable (Rolling Stone)

Tips and Myths About Extending Smartphone Battery Life (New York Times)

The Ad Blocking Wars (New York Times)

Winners of the 2016 World Press Photo Contest (The Atlantic)

Can we make sense of the Malheur mess? (High Country News)

Book roundup, part 21

This installment features grimdark fantasy, peppy astronauts and the Roman Empire. Includes SPQR, And On That Bombshell, The Code Book, Schiit Happened, Beyond Redemption, The Severed Streets, The Martian and Veiled.

The Triumph of Email (The Atlantic)

Space Shuttle Endeavour

Endeavour is a symbol of hope for a better future.

There is nothing makes a man suspect much, more than to know little

The GOP debate described a terrifying world that doesn’t actually exist (Vox)

Review: The Revenant

A great 90 minute movie smothered in a 2-and-a-half-hour wreck.

Why (almost) everything you know about food is wrong (Vox)

Thoughts on the 2016 Prius v after a road trip

After a 1,000 mile road trip in his new Prius, Nic has thoughts and gripes.