I recently had a problem with one of my mail accounts (and before you ask, no, it wasn’t Gmail under Mavericks). The issue was that the account, which is provided by Dreamhost, is located on a mail server named one thing (mail.doombot.com), but is secured with a certificate for a different mail server (mail.dreamhost.com). The result was that every time I opened Mail, I got an error saying that the two certificates didn’t match.
The easiest way to fix this type of issue is to edit a file on your drive called hosts, but it’s located in the hidden /private/etc folder. That’s where Lars van de Kerkhof’s free Hosts System Preferences pane comes in.
If you’re not familiar with the hosts file, it’s essentially a local override for the DNS (Domain Name Server) system. DNS is what takes nice, pretty website addresses (a.k.a., hostnames, such as macworld.com) and translates them into their hard-to-remember, IP-address equivalents (say, 22.214.171.124). The hosts file lets you override the DNS system for particular addresses or ranges of addresses. You just enter, in the text file, the necessary IP addresses and their corresponding hostnames.
If you’re handy with vi, emacs, or another shell-based text editor, you can edit the hosts file using Terminal, but most of us would rather avoid that approach. In addition, once you’ve made changes to the hosts file, you generally have to refresh OS X’s DNS cache before the new settings take effect, and that’s yet another under-the-hood process many Mac users won’t know how to do.
The Hosts preference pane makes these tasks much easier. First, click the padlock icon and enter an admin-level username and password to give yourself access to the hosts file. You can then add a new host/address pair by clicking the plus (+) button, entering the IP address you want to route to, and then entering the hostname you’ll be using for that address. You can edit an existing entry by double-clicking it, or remove an entry by selecting it and clicking the minus (-) button. If you’d instead like to temporarily disable a specific entry, just uncheck the box next to it.
(It’s worth noting that Hosts doesn’t show any commented lines you might have in your hosts file—those lines preceded with the # symbol, which tells the OS to ignore them. It would be useful if Hosts would show these entries and let you manage them like any other.)
Hosts takes care of all the DNS refreshing, so as soon as you’ve finished editing a hostname entry, it’s active (or disabled, as the case may be)—you can verify this by using Terminal or OS X’s Network Utility to ping the new hostname. Hosts also makes backups of your hosts file before and after you make edits, just in case something goes wrong. (These are stored in ~/Library/Application Support/Hosts. If you need to restore, you’ll need to do so manually—it would be nice if Hosts could do this for you, since it involves deleting and moving system-owned files.) And to prevent you from mucking up your network connections, Hosts hides OS X’s default hosts-file entries.
A couple quick tweaks using Hosts saved my email bacon: It let me associate mail.dreamhost.com with the IP address for mail.doombot.com, which means that I no longer get a security warning every time I launch Mail. (It’s worth noting that this particular approach could open up a security loophole where something could, say, masquerade as mail.dreamhost.com, but there’s always a balance between security and convenience.)
You may not need to edit the hosts file very often, but when you do, you’ll be glad you installed Hosts. It doesn’t have a ton of features, but it does its thing with simplicity and elegance.
Note: When you purchase something after clicking links in our articles, we may earn a small commission. Read ouraffiliate link policyfor more details.