Edit Hosts file in Mac OS X Lion
I have seen that the old command, that is, sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/hosts no longer works inside the terminal and instead you get weird, not-so-user friendly errors.

Here is how you get around this problem. Try using this command. Make sure you know your root password.
sudo nano /private/etc/hosts
Type in the password if prompted. Edit the host file and save and close it by using control + o and control + x respectively. To flush the DNS cache, type in dscacheutil -flushcache
