1
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 http://drupal.org/node/463262 (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:
127.0.0.1 localhost gwwc.drupal7.local drupal6.local newni.loc
Somehow it had reverted to an earlier version of the file, containing (among other lines):
127.0.0.1 localhost
192.168.0.18 itdb pat
127.0.0.1 newni.loc
208.89.50.22 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 127.0.0.1 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?
Would this get a better reponse on another StackExchange site? If so, please move it moderators – tog22 – 2011-11-30T16:14:23.160
Migrating to Super User on your request – Kyle Cronin – 2011-12-01T14:53:17.410
Couldn't you just add the additional host names to that second
127.0.0.1
line? Sounds a lot like some system service restoring the single127.0.0.1 localhost
line if changed to prevent things from breaking. – Daniel Beck – 2012-01-07T21:35:49.6231
possible duplicate of /etc/hosts getting reset in Lion — the
– Daniel Beck – 2012-01-07T21:45:10.593dscl
workaround might work for you.I also stumbled upon a blog post than mentioned problems when you saved
/etc/hosts
with the wrong line endings. Make sure it's all UnixLF
, notCR
. – Daniel Beck – 2012-01-07T21:45:48.640Daniel, thanks for pointing me to that post - it pointed me to the answer given below about making the changes in all hosts.* files in /private/etc/ – tog22 – 2012-01-20T14:27:25.570
1@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 – 2012-01-20T14:37:40.690