Hosts File on XP

What's a Hosts File Anyway?

The hosts file is a little file well hidden on computer. Most people don't know they have one. But one day you may need to know.. A hosts file basically controls how your browser finds websites.

Websites have an address just like you do you might live at 123 Main Street. There may be multiple people living at that address - but you are Bob at 123 Main Stree. If you were a website you would have an address too: it would be something like in fact if you type that set of numbers straight into your browser you will come up to a well known site: One of google's addresses is - its called an IP address and every site has one. Some IP addresses belong to only one site, others will have many websites on the same IP address.

Sometimes though you may want to tempoarily change a website's IP address which is when you need to find your hosts file.

Hosts files and IP Addresses!
Hosts files and IP Addresses!

How To Test a New Website Before its "Live"

Think of his scenario - you have an existing website - but you want to change it over a new a hosting provider.On that new hosting provider you want to build an entirely new website. You want to build it, play with it, decide its right BEFORE you swap your website over to its new hosting and new look.

To do this you need to edit the hosts file on your computer. Temporarily you want to see your new site while the rest of the world keeps on seeing the old site.

To do this you need to know two things - the new IP address of your website and where you hosts file is on your PC.

You should know what the IP address of your website is from your hosting account.

To find you hosts file may be a little more difficult! Common locations for Windows machines are:

Windows 95/98/Me: c:\windows\hosts

Windows NT/2000: c:\winnt\system32\drivers\etc\hosts

Windows XP (Home OR Pro): c:\windows\system32\drivers\etc\hosts

When you find that file you want to add a single line to it:

where is your NEW IP adress and is your domain

Step By Step Editing Your Hosts File

Step-by-Step Editing a Hosts File

If you're not confident editing a hosts file then follow this video along step by step - until they open up the hosts file in notepad. Ignore the bit about pinging to get an IP address.

Just add the ext ra line with

<new IP> <website name>

save and close.

Close your browser if you have it open

Restart your browser

You should see your new site (if you don' try ctrl-F5 to clear the cache)

When Things Go Wrong

If you find lots and lots of lines in your hots file its probably just your spywear program blocking sites by adding lines like

This is fine - ignore them - just add your line in and save.

You will need adminstrator rights to edit the hosts file - login in as admin if you are not already.

Your file may be read only - right click and change this before you open it with wordpad

Don't use anything but a text editor on a text file - Word will add all types of invisible rubbish to the file even if you save as text.

Dont try to save as the file - "helpful" windows will insist on calling in hosts.txt which is NOT the name it has to be hosts no extension. If you want to keep a copy - copy hosts to hosts-old before you start and then edit hosts and "save" it not "save as".

Oh and once your site is moved over to the new hosting don't forget to delete this line! Or copy back the saved hosts file to hosts!

This hub is for Sue who builds quality log homes and taught me a lot about hosts files!


Comments 13 comments

ajcor profile image

ajcor 7 years ago from NSW. Australia

Thank you Lissie - see you're up to 114 hubs - how many have you done for the hub challenge? go well.....cheers

Lissie profile image

Lissie 7 years ago from New Zealand Author

Thanks ajocor - its the 16th - but the first as &quot;lissie&quot;!

profile image

artspeck 7 years ago

Thanks for such an informative hub Lissie. It scares me to consider doing this myself, even though I'm desperate to change providers for one of my websites. Must study this for a week or two to get the confidence to try it.

Lissie profile image

Lissie 7 years ago from New Zealand Author

artspeck - it sounds difficult but its not really. Though if you are just changing hosting providers you don't need to do this - you need to change the nameservers to point to the new host - but that's another hub!

agrande profile image

agrande 7 years ago from Oregon, USA

Great informative post as usual Lis. You are really a renesaunce woman. Dancing, computers, IM. What's next?

(I really wish they had a spell checker on these comments as you can see above, I actually meant renaissance, LOL)

Lissie profile image

Lissie 7 years ago from New Zealand Author

Haha I know a horrible amount of basic unix from a long time ago -it was so painful learning it by trial and error - it always come back when I need to use it again - even if I havent' thought about it for years

In case anyone cares the reason that the hosts file has not extension is because on unix you don't have extensions - the OS is smart enough what to do with a file without an extension! Hosts has been around since at least the 1960s AFAIK - much longer than windows. Obviously someone took the concept straight over to Windows and didn't know that ever other file in Windows has an extension... 

agrande - you forgot the travel, I speak a little Spanish and I can cook. I guess I'm the classic "student of everything master of none"!

Montana Farm Girl profile image

Montana Farm Girl 7 years ago from Northwestern Montana

Very informative, great hub!!!

thelesleyshow profile image

thelesleyshow 7 years ago from US

This sounds less painful than some of the other instructions I have read. Good job. Thanks for sharing. Thumbs up!

BirteEdwards profile image

BirteEdwards 7 years ago

I have no idea if I will ever need to do this myself. But even if not the information is invaluable.

When running businesses over the web, we should know about things like this, even if we don't have to do it ourselves. But I have also learned that a lot of this tech stuff is not so complicated, if you have good instructions, as you have provided

yav 7 years ago

How do i change the hosts file in xp to have full control and also always open with notepad

profile image

BestWebHosting911 6 years ago

thank you soo much , you have no Idea that I am looking for this information for a weeks, cause what you've just writes about

this Windows XP (Home OR Pro): c:\windows\system32\drivers\etc\hosts

is location that I am looking for, and some hacker redirect my site to appropriates content,by using this files , anyway thanks for sharing I think I will revenges to them and get theirs site down , lol :)

thanks again your my Hero , and I am not kidding about this,

satish kr 5 years ago

Thanks a lot

crazyazz 4 years ago

i am impressed. ill say this. took almost 15 minutes ta find this hub good job , a admirer .tx fer the info

    Sign in or sign up and post using a HubPages Network account.

    0 of 8192 characters used
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your articles or other sites.

    More by this Author

    • Moving to Australia

      You live in the Northern Hemisphere - winter is closing in the dream of beautiful, clean empty Australian beaches beckon. Or maybe the housing market is rubbish, the cost of living is ridiculous and you want to escape...

    • Skirts For Men

      Skirts are not seen as mainstream fashion in many western countries: well in the USA anyway. Well this is my hub to prove that it is in fact pretty common in many cultures for men to wear skirts or long-flowing robes. ...

    • Driving Across the Nullarbor: A How To Guide

      Driving the Nullarbor plain of Australia is one of those things you just have to do once in a life time. Its an accessible adventure, which unlike many other of Australia's iconic drives doesn't require a 4WD - but it...

    Click to Rate This Article