I need to add an entry to my hosts file on Snow Leopard. I could edit the hosts file with root user enabled, but in the system doesn't let me to save this file saying that I don't have permissions to make changes to this file since it's located in non-writable directory. How do i save changes there?



2 Answers 2


Try it from the command line:

sudo nano /private/etc/hosts

Type your user password when prompted for a password.

For more help, please refer to this blog posting:


Please note that you might have to reset the DNS cache with this command after changing the hosts file:

dscacheutil -flushcache

  • 1
    You can only use sudo if you're logged in as an administrator. If you're not an administrator do su -l <admin-account-name> first. Jan 3, 2010 at 14:54
  • well, i did it with vi (and i hate it). nano seems much more user friendly. Thanks anyway Jan 3, 2010 at 15:54

Wat you could also do, is copying the file to anywhere else, and edit & save it from there. Now drag and drop it in finder in the /private/etc/ folder. It should ask for admin permissions; just type in your admin password. Also, you probably have to change permissions on the hosts file afterwards.

  • If you use this method be mindful of line endings.
    – ridogi
    Jan 3, 2010 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.