web hosting uk

knowledgebase

How to configure your host file

What Is a Hosts File?

The hosts file is used by your computer’s operating system to map various hostnames to
IP addresses.

The hosts file is a plain text file, and is usually named hosts.

A typical hosts file will have one or more lines referencing your
computer (as ‘localhost’) and will resemble something like this below:

Copyright (c) 1993-2006 Microsoft Corp. # This is a sample HOSTS file used by Microsoft TCP/IP for Windows. # # This file contains the mappings of IP addresses to host names. Each # entry should be kept on an individual line. The IP address should # be placed in the first column followed by the corresponding host name. # The IP address and the host name should be separated by at least one # space. # # Additionally, comments (such as these) may be inserted on individual # lines or following the machine name denoted by a '#' symbol. # # For example: # # 102.54.94.97 rhino.acme.com # source server # 38.25.63.10 x.acme.com # x client host 127.0.0.1 localhost ::1 localhost

A hosts file can be edited to override your network settings and allow
your computer to view a website prior to the DNS changes propagating.
you will need to add a few lines to bottom of the host file
for example to point to an account on our server our ip address is 91.103.220.60

91.103.220.60   example.com
91.103.220.60   www.example.com

change example.com for your domain name
and remember to leave a space between the IP address and your domain name

so it should look like this

Copyright (c) 1993-2006 Microsoft Corp. # This is a sample HOSTS file used by Microsoft TCP/IP for Windows. # # This file contains the mappings of IP addresses to host names. Each # entry should be kept on an individual line. The IP address should # be placed in the first column followed by the corresponding host name. # The IP address and the host name should be separated by at least one # space. # # Additionally, comments (such as these) may be inserted on individual # lines or following the machine name denoted by a '#' symbol. # # For example: # # 102.54.94.97 rhino.acme.com # source server # 38.25.63.10 x.acme.com # x client host 127.0.0.1 localhost ::1 localhost 91.103.220.60   example.com 91.103.220.60   www.example.com

Best way to edit the host file


Windows XP

  1. 1 Browse to Start > Find > Files and Folders.
  2. 2 Select the hosts file in your Windows directory (or WINNT\system32\drivers\etc).
  3. 3 Verify that the file is not “read only” by right-clicking it, and choosing Properties.
  4. 4 Open the file for editing with Notepad.
  5. 5 There should already be an entry for “localhost.” Earlier versions of Windows have different formats for hosts file entries. Be sure to follow the same format as you find in your file when inserting the hostanddesign IP and the domain name:

On Windows98 and Windows95, the order may be hostname, IP address.

On Windows2000 and WindowsME, the order is IP address, hostname.

Make the needed changes and close Notepad.
Save when prompted.

You may also need to reboot for the change to take effect. The next time you visit your domain, your browser will try to find the domain at the corresponding IP instead of looking up the IP through DNS.


Windows 7 or Vista

  1. 1 Browse to Start > All Programs > Accessories.
  2. 2 Right-click Notepad, and select Run as administrator.
  3. 3 Click Continue on the UAC prompt.
  4. 4 Click File > Open.
  5. 5 Browse to C:\Windows\System32\Drivers\etc.
  6. 6 Change the file filter drop-down box from Text Documents (*.txt) to All Files (*.*).
  7. 7 Select hosts, and click Open.
  8. 8 Make the needed changes, as shown above, and close Notepad.
  9. 9 Save when prompted.

Windows 8

  Select the Start key and locate Notepad.(If you do not see it on your current Start page, begin typing “Notepad”
  and a search box will appear on the right side of the screen with a list of programs under it. Notepad should be at the top of this list.

Right click on Notepad. You will see options appear on the bottom portion of
the Start Page.

   Select Run as administrator.

Please Note: Performing this action may cause Windows User Account Control to
prompt you with a warning or, if you are logged in as another user, a request
for the Administrator password. This step is necessary to modify system files
such as the hosts file.

  1. 1 Click File in the menu bar at the top of Notepad and select Open.
  2. 2 Click the dropdown box in the lower right hand corner that is set to Text Documents (*.txt) and select All Files (*.*)
  3. 3 Browse to C:\Windows\System32\Drivers\etc and open the hosts file.
  4. 4 Make the needed changes, as shown above, and close Notepad.
  5. 5 Save when prompted.

mac os x

  Follow the instructions below to edit your hosts file if you are running Mac OS X.

  1. Open the Terminal application. Start by typing Terminal on the Spotlight or by going to Applications > Utilities > Terminal.
  2. Open the hosts file by typing in the Terminal that you have just opened:

sudo nano /private/etc/hosts

Please Note: Some versions of Mac OS X will lock permissions on the hosts file (the file is marked as immutable).
In the event this happens, use the following command instead:

sudo chflags nouchg /private/etc/host

Type your user password when prompted.
The hosts file contains some comments (lines starting with the # symbol), as above, You can navigate the file using the arrow keys.

149.255.58.106 example.com www.example.com

Replace example.com with your actual domain name. Additional domains, subdomains or addon domains (such as www.domain.com) can be added at the end of the line, separated by spaces.
When done editing the hosts file, press Control-o to save the file.
Press Enter on the filename prompt, and Control-x to exit the editor.


Unix

On Unix-based systems, you can find the hosts file at /etc/hosts. Most distributions of Unix will have terminal located in the same place.

To open the terminal:

Go to Menu.
Select Applications.
Choose Accessories.
Select Terminal.

  1. Open the hosts file by typing in the Terminal that you have just opened:

sudo nano /private/etc/hosts

Type your user password when prompted.
The hosts file may contain some comments (lines starting with the # symbol), as shown above

enter at the bottom of the file
149.255.58.106 example.com www.example.com

Replace example.com with your actual domain name. Additional domains, subdomains or addon domains (such as www.domain.com) can be added at the end of the line, separated by spaces.
When done editing the hosts file, press Control-o to save the file.
and press control-x to exit the terminal.