Prefer getting straight to the point?

Join our weekly "Consulting content round-up" newsletter to get a succinct, straight to the point email with the most relevant information to help you scale your consultancy.

How To Update The Hosts File On Windows 7 & Windows 8

update the hosts file on Windows 7 and Windows 8

Last week we published a post on how to update the hosts file on Mac OS X (click here to read the post). So this week, we wanted to explain how to update the hosts file on Windows 7 and Windows 8.

When you are building new websites for clients, one of the most common things that you need to do is either access the new website as it would be accessed on the current domain name, or when the site is live access the old version of the website.

One of the easiest ways of doing this is via the hosts file on the local computer.

The hosts file is basically a text file on your local computer that your internet browser references before it accesses the IP address details of the domain from the internet. If it finds the details for a domain in the hosts file it will use these rather than requesting the IP address from the Internet (DNS).

Here are instructions on how to update the hosts file on a Windows 7 computer. It will be pretty much the same on a Windows 8 computer.

Step 1 – Open notepad as administrator

  • Open the Windows Start menu and locate Notepad, this can typically be found under All Programs > Accessories
  • Right click the notepad icon and select Run as administrator

Update Hosts File On Windows 7 and 8 Open Notepad

  • Select Yes, for the allow this program to make updates on my computer

Step 2 – Locate and open your hosts file

Open the Hosts file File > Open
My Computer > C > Windows > System32 > Drivers > etc
Select All files in the file type drop down to display the files
Double click hosts to open it

Update Hosts File Windows 7 and 8 Open The File

Step 3 – Update and save the hosts file

  • Now you can add the domain you want to the bottom of the hosts file. This should be in the format IP address <tab> domain name. Enter the full domain including sub domain that you want to access, as in the examples below:

111.111.111.111 domainname.com
222.222.222.222 www.otherdomain.com

Update And Save The Hosts File

Save the Hosts file File > Save and then close it

Step 4 – Flush the DNS Cache and test the domain name

In the Command prompt type:

Ipconfig/flushdns

Flush The DNS Cache

To be on the safe side close and reopen your browser. You can now enter the domain name you have added to the hosts file in your browser and it should open the website you expect.

If it isn’t, test ping the domain to check that it returns the website address you have entered in the hosts file. If everything is set-up correctly the address you entered in your hosts file should be returned as the result of the ping.

My hosts file didn’t save correctly – what should I do?

  • If your hosts file doesn’t update successfully, check that you saved it correctly. It should be saved as hosts with no file extension etc. Sometimes if you saved it as a text file the .txt extension will have been added and it won’t work. Go through the process above and when you save the file make sure the file type drop down in notepad is set to All files.
  • Check if you have an antivirus installed. Sometimes this will prevent the hosts file from being modified. If it is, you may need to disable your antivirus program while you make the hosts file update. You should be able to start the antivirus again after making the changes. If you are having these problems it will be best to search on your antivirus program and hosts file update – it is pretty likely someone technical will have posted a solution.

A couple of other points on your hosts file

  • Remember you have updated your hosts file. If you forget, there may be some head scratching moments wondering where your old website has all of a sudden appeared from!
  • If you want to keep a website’s details in the hosts file, but don’t want it used you can comment it out – just pop a hash character in front of the line #

If you’ve got any queries, let us know via marketing@lexisclick.com.

  

 

Prefer getting straight to the point?

Join our weekly "Consulting content round-up" newsletter to get a succinct, straight to the point email with the most relevant information to help you scale your consultancy.