'localhost' stoped working as an alias for '127.0.0.1' for SSHing into my VirtualBox VM. Why, and how to fix?
[This is copied &amp; slightly expanded from my answer on Superuser.]

localhost is normally defined in the /etc/hosts file, not in DNS (although your DNS has an emergency backup entry for it). Here's the normal contents of /etc/hosts in OS X (as of Mavericks):

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


Note that if you need to edit/recreate this file, it must be in plain text format (no formatting at all), with unix-style line endings (linefeeds). You can use a command line editor like vi or nano; if you want a GUI editor, I tend to recommend TextWrangler or its big brother BBEdit for editing files like this, since they're good about not adding spurious "helpful" things to the files you edit, and also can use admin rights to edit system files (like /etc/hosts).

(Also, it's not really visible or important, but those are tab characters between the addresses and names.)

For testing lookups like this, use dscacheutil (dscacheutil -q host -a name localhost) instead of something like dig. The reason to use dscacheutil is that dig (and host and nsloogup) bypasses the system lookup policy and just checks DNS directly, while dscacheutil uses the full system lookup policy. As a result, dig won't see entries in /etc/hosts, or do mDNS (Bonjour) lookups, or look for Computer entries in directory services, or see cached entries from previous lookups, or...

When you have the hosts file set up properly, here's what dscacheutil's output should look like:

$ dscacheutil -q host -a name localhost
name: localhost
ipv6_address: ::1
ipv6_address: fe80:1::1

name: localhost
ip_address: 127.0.0.1