Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm doing web development on Mac OS X (10.6) and to speed this up created a few virtual hosts with short, easy-to-type names like sandbox.drupal7.loc and gwwc.drupal7.loc. I did so following the instructions at (which involve editing /etc/hosts among other things). Initially this worked but at some unknown point, it has stopped working.

Viewing /etc/hosts shows that the following line that I needed has been deleted:       localhost gwwc.drupal7.local drupal6.local newni.loc

Somehow it had reverted to an earlier version of the file, containing (among other lines):       localhost    itdb pat       newni.loc    jura

The non 127 IPs are not related to my testing issues and they're just there as an example. I can add back my line to the file and the changes stay until restart, but these changes are not surviving a reboot.

When I add back drupal6.local to the line in /etc/hosts fixed things that session 'work' in that it doesn't yield 'Server not found' but it doesn't reach my non-default ghost as configured in /Applications/MAMP/conf/apache/httpd.conf

Could this be somehow related? Is there a robust solution to hard coding entries in /etc/hosts on Snow Leopard?

share|improve this question

migrated from Dec 1 '11 at 14:53

This question came from our site for power users of Apple hardware and software.

Would this get a better reponse on another StackExchange site? If so, please move it moderators – tog22 Nov 30 '11 at 16:14
Migrating to Super User on your request – Kyle Cronin Dec 1 '11 at 14:53
Couldn't you just add the additional host names to that second line? Sounds a lot like some system service restoring the single localhost line if changed to prevent things from breaking. – Daniel Beck Jan 7 '12 at 21:35
possible duplicate of /etc/hosts getting reset in Lion — the dscl workaround might work for you. – Daniel Beck Jan 7 '12 at 21:45
@tog22 You're welcome. Note that you need to prefix user names with an @ so they receive a notification about your comments (like I just did), if they're not author of the post you're commenting on. Otherwise they might never see your comment. – Daniel Beck Jan 20 '12 at 14:37
up vote 1 down vote accepted

I fixed this by making my changes in all files starting 'hosts.*' in /private/etc/, e.g. /private/etc/ (answer found via etc-hosts-getting-reset-in-lion)

share|improve this answer

As per this site, I believe you need to edit /private/etc/hosts (with root privileges of course) and not /etc/hosts.

share|improve this answer
/etc is a symbolic link to /private/etc, so that doesn't make a difference. – Daniel Beck Jan 7 '12 at 21:32
Fair enough, didn't catch that one. You did edit it with root privileges though, right? – Marvin Pinto Jan 7 '12 at 21:36
Yes, I have explicitly edited /private/etc/hosts (always as sudo) with the same problem. – tog22 Jan 18 '12 at 14:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .