Can't update hosts file on mac

When I try to save changes made to / etc / hosts file on mac, I get this error:

"hosts" E212: Can't open file for writing

How can I update it?

+4


source to share


3 answers


I found a solution:

just use "sudo" in front of vi hosts (it will ask for the admin password) By doing this, I basically open the hosts files with administrator privileges:



$ sudo vi hosts

      

and after modifications it :wq

works just fine!

+7


source


Start Terminal

  $ sudo vi /etc/hosts

      



and after improvements

 :wq!

      

0


source


My problem was that I was running sudo vi etc/hosts

instead of sudo vi/etc/hosts

¯_ (ツ) _ / ¯

0


source







All Articles