7 Replies Latest reply: May 5, 2011 5:33 AM by plcn
doktorV Level 1 Level 1 (0 points)

I cannot access a favourite website at the moment and this is recognised by the site. the advice is to add the IP address and name to the host files but i am baffled as to how to do this!! I gather it has something to do with simply going to "/etc/hosts" .....but how do I get there/do this? I've tried opening applications/terminal then typing the above in but it says permission denied. Please help!!

  • plcn Level 2 Level 2 (325 points)

    You need the terminal to do it:


    - Open terminal.

    - Type: sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/hosts

    - Enter your password.

    - In TextEdit, edit the file and save it.

  • thomas_r. Level 7 Level 7 (30,630 points)

    Although you can open the /etc/hosts file and add a line mapping an IP address to a domain name, that is not a proper solution to this problem.  If you are having trouble accessing a site via its domain name but not by IP address, that indicates a problem with your selected DNS server.  You may need to switch to another DNS server, such as the Google DNS servers or OpenDNS.

  • doktorV Level 1 Level 1 (0 points)

    thanks but a few more questions as that didn't seem to work (sorry if this is super-basic and i'm being a dunce - not long had a mac and definitely never done anything like this before or used Terminal)


    1. i typed what you said to above and hit Return. It gave me a warning about sudo commands having potential harmful effects but after putting it in, it then simply wrote this next:

    sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit/etc/hosts : command not found



    2. Was I wrong to hit Return after typing what you said or should I have put in a space and then my password then hit Return?


    3. is there something specific about the way you typed that eg. the space between 'sudo' and the '/Applications' - is that on purpose?


    4. what is TextEdit where I 'edit the file and save it'? is that a program or application? (again...sorry if i am asking really simple/obvious questions!)


    Thanks for the quick reply before. :-)

  • plcn Level 2 Level 2 (325 points)



    First of all, you need a space between "sudo", "/Applications/TextEdit.app/Contents/MacOS/TextEdit" and "/etc/hosts". Paste the following (without quotes): "sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/hosts". The command will open the /etc/host file with TextEdit, a graphical editor, with administrator permissions (for modifying the /etc/hosts).


    Hit return, and you will be prompted for your password. Enter it and hit enter.


    TextEdit, the Mac OS X "notepad" will open and you will see the content of the /etc/hosts file. Add the desired entries, then save the file and quit TextEdit

  • noondaywitch Level 6 Level 6 (8,130 points)

    All the spaces are important; you missed the one between 'text edit' and '/etc/hosts'. Try copying and pasting the line.

  • doktorV Level 1 Level 1 (0 points)

    thank you everyone for your advice and thanks heaps picn - it worked!


    point taken thomas - i ahd come across this earlier on another forum where someone made the point that when the site alters/mends the issue it may/will be with a different address? in which case i'd have to go back into this i assume and delete what i just put in?


    cheers again everyone for your help :-)

  • plcn Level 2 Level 2 (325 points)

    You are wellcome. Please, use the "correct answer" and the "helpful answer" marks for our advices