Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

HOSTS file does not retain changes between boots

I make a number of changes to my HOSTS file for various reasons. Lately, though, I've noticed that attempts to alter the HOSTS file are reverted automatically for some reason.


I modify my HOSTS file by using the command at the terminal: sudo nano /private/etc/hosts


After editing the HOSTS file, I will save while exiting with control+X. At this point the changes are retained. Looking at /private/etc/hosts or /etc/hosts will show the changes I've made. Pining the domains I've modified will show the relevant changes.


Everything is working at this point.


However, at some point after a reboot, the HOSTS file will revert all of my changes without my asking. Looking at the HOSTS file will show it in the state it was before I made any changes at all, despite the file being modified and saved in the previous session.


Could anyone please advise as to how I can permenantly modify my HOSTS file? Again, I AM editing the file as root, and I AM saving the file. It works fine until reboot.


Thanks for any help.

MacBook Pro, Mac OS X (10.6.8)

Posted on Dec 10, 2011 6:36 AM

Reply
Question marked as Best reply

Posted on Dec 10, 2011 7:15 AM

These are one of the weirdness of OS X.


You never know what is better to change. Plain standard text files or Directory Service database.


This should work


sudo dscl localhost -create /Local/Default/Hosts/donalduck IPAddress 192.168.1.15


use it for each entry you need to add at your hosts file.

7 replies

Dec 11, 2011 9:49 PM in response to midlova

Well, Lions have no business posting here -- you're different beasts and you have your own lair. To give you a clue and speed you on your way, here's a blog entry that might help.


Now that we're between us solitary cats, it's a curious business. It's been solved already to the OP's satisfaction, but I'd've been curious about /etc/hosts's modified and access timestamps before and after rebooting, and about line endings. I assume, of course, that the OP flushed the cache after modifying /etc/hosts.

HOSTS file does not retain changes between boots

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.