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!
source
to share