Knowledgebase: DNS and Domain
How do I add my domain name to my computers host file?
Posted by Support, Last modified by Support on 12 September 2013 01:44 PM


    • Open Notepad and then open the "Hosts" file on your computer. The location of the "Hosts" file is as follows:

      Windows 95/98/Me:  c:\windows\hosts
      Windows NT/2000/XP Pro:  c:\winnt\system32\drivers\etc\hosts
      Windows XP Home: c:\windows\system32\drivers\etc\hosts
      Windows Vista/7/8: c:\windows\system32\drivers\etc\hosts

      You may need administrator access for Windows NT/2000/XP/Vista/7/8, you can gain this by logging in as an Administrator or by right clicking on Notepad in the start menu and then clicking on Run As Administrator. Then open the file listed above.

      NOTE: Hosts is the name of the hosts file and not another directory name. It does not have an file extension (extensions are the .exe, .txt, .doc, etc. endings to filenames) and so appears to be another directory in the example above.

      This file should be edited with a text editor, such as Notepad, and not a word processor, such as Microsoft Word.

    • Add this line to the Hosts file at the bottom where is the IP address and is the domain name.


  • Save your changes.
  • Once you are done with this entry you can delete the line from your Hosts file and save it.

    NOTE: Windows users should verify that they are showing extensions for all file types. This will help verify that the Hosts file is named correctly. To reset Windows to show all file extensions, double click on My Computer. Go to View Menu (Win95/98/ME) or Tools Menu (Win2000/XP), and select Folder Options. Click the View tab. In the Files and Folders section, DESELECT (uncheck) the item named "Hide file extensions for known file types". Click Apply, and then click OK.



    • Edit the hosts file on your system. The hosts file is usually found in


  • Add this line to the Hosts file at the bottom where is the IP address and is the domain name.

  • Now make sure this file is used for host name lookups. This is done in two files. First is:



This file should have at least the line shown below:

order hosts,bind

That has host lookups use the hosts file before doing a DNS query with bind.


  • The next file is:



Recent tests indicate that this file is required in order for the pserver to use the entry in /etc/hosts. The nsswitch.conf file should have this line for the hosts configuration:

hosts:      files nisplus nis dns

There will probably already be a similar line in your version of this file. Just make sure "files" comes before whatever other methods are listed.


  • There is no need to reboot your system.

Macintosh OS X


  • With Macintosh OS X, the procedure is similar to Linux above. The hosts file can be found in

Macintosh OS 9

    • Look in System Folder:Preferences, and in the System Folder itself, and see if you have a file named "Hosts". If not, create one in a text editor.

    • Add this line to the Hosts file at the bottom where is the IP address and is the domain name.     A


  • Spaces should work, but it is recommended that you separate the three entries on each line by tabs. Place the Hosts file in System Folder:Preferences and reboot your Mac.

    If you have an older Mac that is using MacTCP instead of Open Transport, try putting the Hosts file in the System Folder.

  • Note from the Apple Tech Info Library:

    Open Transport TCP/IP automatically uses a Hosts file stored the Preferences folder of the active System Folder. If no Hosts file is found in the Preferences folder, Open Transport TCP/IP searches the active System Folder for a Hosts file.

    This means that if you don't already have a Hosts file, and you just drop it in your System Folder and reboot, it will work. However, System Folder:Preferences is the default and recommended location for all systems using Open Transport.

  • Additional Configuration Options

    You can configure TCP/IP to use the contents of this new Hosts file, which will activate the Hosts file without having to reboot.

    To do this:

    • Open the TCP/IP control panel.
    • Get into Advanced user mode by:
      • selecting the User Mode command under the Edit menu.
      • In the User Mode dialog select Advanced then click OK.
    • Click on the Select Hosts File button.
    • In the File Open file dialog that comes up, naviagate to and select the Hosts file you created.
    • Click on OK if it asks you if you are sure you want to replace the Hosts File with the contents of the selected file.
    • Close TCP/IP control panel and click OK to save the configuration.

    The above procedure will copy the contents of the file selected into the Hosts file in the Preferences folder, or create one there if none exists.



(1027 vote(s))
Not helpful

Comments (0)