Did your localhost or virtual hosts stop working and won’t resolve for some reason? Don’t freak out, panic, and/or format your computer! (I already went through the trouble for you). This problem began for me after I upgraded my OS to Mac OS X 10.8.2. The fix is easy.
If your localhost or virtual hosts were working fine and then suddenly stopped working (especially after you upgraded to OS X 10.8.2), your hosts file’s line endings may have changed, causing your hosts file to be ignored—your hosts file’s (/etc/hosts) line endings needs to be set to LF.
The steps below are instructions if you have and are using TextMate installed with shell support (Terminal).
Open up Terminal and run the following command:
Go to File & Save As and select LF (recommended) as your line endings and save the file. (You should see a dropdown above the Save button)