How to edit the hosts file on Windows
Articles,  Blog

How to edit the hosts file on Windows


Hi this is Andrew from 20i and today we’re
going to be looking at how to perform a host file override on a Windows machine.
Knowing how to edit a host file is a handy tool to have in your arsenal when
migrating from one provider to another or just in general as a web designer
slash hosting provider. Modifying a host file enables you to override DNS for a
domain on that particular machine. This is useful if you wish to test a domain
without using the temp URL that we make available in our control panel or if
you’re unable to for one reason or another. It’s also great if you wish to
look at a domain on our platform and see how it works if it works okay without
having to amend DNS and incurring possible downtime if there are any
issues with the website. From a technical standpoint a hosts file is essentially a
‘txt’ file on your local machine in which the mapping of host names to IP
addresses can be defined. So essentially it’s just a great tool that allows you
to look at a domain on our platform without having to mess around with any
DNS changes so in order to implement a host file override in order to edit a
host file we need a host name and for the purposes of this tutorial the host
name will be just a domain name that’s linked to a package here. And we need an
IP address and the IP address will be the IP address of the package here at 20i. So going forward we want to get the IP address of a particular package that we
have here that we want to take a look at. So to do this we go to my.20i.com
and on this page we want to look under ‘Reseller Management’ and ‘Manage Hosting’.
Once we’ve gone to Manage Hosting we then want to go to ‘Manage’. Once we’ve
done this, on the right-hand side of the page we can see ‘Account Information’.
Under Account Information we can see the domain that we wish to do this for or at
least the package/host name that we wish to do this for and we can see
the IP address here. So now that we have both of these – or at
least the IP address – we want to go ahead and perform the hosts file override and
edit the hosts file. To do this we need a text editor. For the purposes of this
tutorial we’ll be using Notepad but you can use your own, for example Notepad++ etc. So, we need to go ahead and open up Notepad. It’s vital here that we
run as administrator as the host file amendment requires administrator
privileges. So here we’re going to right-click Notepad. If it doesn’t appear
here just type it in and we need to right click Notepad and ‘Run as
Administrator’. Once we’ve done this we now want to open up local hosts file. So to
do so we need to go to File and Open. Once we’ve done this we need to go to
Computer we need to select the hard disk for the Windows OS. So for this purpose
for this video I have installed to ‘C’. We then go to Windows. We then scroll
down and go to System32. Once here we then go to drivers and here we go to
‘etc’. Once you’ve done this you may see a blank directory listing. All
you want to do here is change this from ‘Txt’ to ‘All files’. Once you’ve done that
press ‘hosts’ let’s select ‘hosts’ and then press ‘Open’. Once that’s opened you should
then see your host file. So here we can see an example so we can see that the
rhino.acme host name is mapped to that IP address and it gives another
example here regarding local host. So here we want to add the IP address and
the host name the hostname being the the name of the
20i package. So here we grab the IP that we wish to force the hostname to look
at just for this local machine. Once we’ve copied that we paste it here. We
now want to enter the hostname so we just want to add a space and then we
want to add intended host name that we wish to force to the IP there. So what
this will do now that that’s there and when we save that will force this
hostname – so 20isupport.com – to go to that IP address just for our local
machine and that will ignore any DNS that is actually in force for the domain.
For here this will only force 20isupport.com. If we wish to test the site
over ‘www’ we need to enter ‘www’ and then
the domain name. So that will then force both non-www and www to 20isupport.com to point towards the IP ending in .150. Once we’re happy
with that change we then just need to press ‘Save’. If we then close that and go
to the domain name we should then see the site as it is on our platform. And
for example in the bottom right hand corner here a Google Chrome plugin I
have indicates that the domain as a result of the host file override is
indeed pointing to an IP ending in .150. So again this essentially just
allows you to view a site as it is in our platform without making any
complicated DNS changes and just so that you can work on it without having to
update DNS and possibly incur downtime on the domain. Once you no longer need the the host file override it is recommended that you
remove the record from the host file. Let’s do this: you just go back here and
just delete and save that line. Hopefully this has helped. If you have
any questions or any issues please get in touch of our Support team, who will be
more than happy to help. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *