Home / Knowledge Base / Pre-Launch / Editing "Hosts" Files

Editing "Hosts" Files

Viewing Websites Before Launch

Sometimes, when launching a new website, the new website is on a new hosting account or on a new IP address. Launching a website this way actually has some benefits because there's a way to view it in that environment before the general public can. We will explain here how to do that.

Please note that this does not apply for every website launch that we do. There is usually a staging website where the new website can be viewed and this is not what we're talking about there. That's completely different. Only follow the instructions here if you are asked to do so. When that happens, we will give you the IP address to use - and you would use your own domain name, of course.

Editing Your Computer's "Hosts" File

"Wait, Wait, Wait... What Are We Trying to Do, First of All?"

Ok, what we're trying to do here is sort of trick your computer into looking at the new website on the new server / IP address instead of going to where everyone else thinks it is. The way this works is that we're overriding DNS settings.

Normally (to get a bit technical), your computer gets access to some DNS (Domain Name Service) servers when it joins the Internet. These are usually provided by your ISP (Internet Service Provider). What DNS mainly does is convert a domain name to an IP address. Computers understand IP addresses and that's what they need. The SOA (start of authority) for your domain name is your domain name registrar (where you registered / bought your domain name). There, you say which DNS server is the authority for your domain name and that is where records are created saying which IP address should be used for the website and for email, etc.

Again, to be clear, there are DNS servers for your domain name (website) and also the DNS servers that you use when you connect to the Internet through your ISP - yeah, it's a little confusing but it'll start to make more sense and we'll explain that more at the end if you want to learn more.

The way to get around using DNS is to manually edit your "hosts" file on your computer. Your computer actually checks that file first before it goes and looks for the IP address it needs on DNS servers. We can then put entries in that file saying that we want just our computer to go to a certain IP address instead of what other DNS servers might say. It's a great way to test stuff.

Ok, I Get It. How Do I Edit the File?

The method you use will depend on if you're using a PC or Mac:

For a PC / Windows Computer:

Step 1: Go to C:\WINDOWS\system32\drivers\etc

- "What? Go where?"

Use Windows Explorer ("My Computer") and find this file on your hard drive.

Step 2: Open the file called "hosts"

- "Open it with what?"

Right click on it and choose to open it with Notepad, which is a plain text editor (don't use Word).

Step 3: Go to the last line of that file and add the IP address and domain name that we give you.

- It will look something like this (do not use this): webstix.com www.webstix.com

- Make sure there's a space between the IP address and the domain name. A tab is ok, too.

- Enter both lines by hitting the enter key at the end of the line (the "www" version and non-www version of the domain name)

Step 4: Save the file.

- You will later want to go and edit this file and take out these two lines once your new website launches.

Here's a video to help explain it:

Free Software

There's also this software for PCs/Windows that might help if you don't want to do what we list above:

Windows Hosts File Editor (download.cnet.com)

For a Mac:

Step 1: Open the terminal application. (Go to: Go > Utilities in the Finder).

Step 2: Type this in:

sudo vi /etc/hosts

- It will most likely ask you for your password. Put that in when it asks.

Step 3: Add a new line to the end and add the IP address and domain name that we give you.

- It will look something like this (do not use this): webstix.com www.webstix.com

- To do this (if you're not familiar with the "vi" program), do the following:

  • Type "G" (shift + g) to go to the last line of the file.
  • Type "o" (lower case "o") to add a new line.
  • Copy and paste in the two lines that we have given you.

Step 4: Save the file.

  • Press the <Esc> key (to get out of edit more) and then type ":wq" (colon + "w" for write and "q" for quit) and hit enter.

- You will later want to go and edit this file and take out these two lines once your new website launches. Here's how to do that:

  • Get back into the same file with the same "sudo vi /etc/hosts" command.
  • Go to the line you wand to delete.
  • Type "dd" to delete the current line.
  • Save the file with ":wq" and enter.

Notes for both PCs and Macs:

Note 1: Do not include a "https://" in the file - you are using a domain name in the file, not a URL.

Note 2: If you are not seeing the new website, then try restarting your web browser or the computer. It should then take effect.

DNS Propagation

"What's that? It sounds kind of sexy."

You're actually done changing the settings on your computer to see the new website but we wanted to explain a little more why we're doing this and how DNS works. This is just FYI but it's good information to know.

As we said, you set your main name server (DNS server) where you registered your domain name. Records for your website and email are set up there so that you specify where your website it located on the Internet. The thing about these DNS servers is, if there were only a few of them, these constant lookups would take forever with everyone trying to use them. They couldn't handle the traffic. The solution for this is to set up lots of DNS servers and then have those servers cache (or save) their own versions of those DNS records. This works well. Your local ISP does this and that's why you get to use their DNS servers.

The only problem with DNS servers is that they are not always up to date. They usually are but if there's a new change, then they won't have it right away. Your DNS records specify how long each record is good for once another DNS server grabs a copy of it. This duration is called the TTL ("time to live"). This could be set for 5 minutes, 5 hours, 5 days or a week. The longer the duration, the fewer DNS lookups are needed and this can actually speed up the time it takes to load your website. It's good to keep the TTL kind of high. But, if you are planning to move your website soon, then your website company (or you) need to go in about a week before launch and change the TTL so that it is being checked more often. It should be set down to an hour or something like that. Then, once the launch happens, the new TTL can be back up to a week or so.

Get found, increase conversion!
Website Marketing
Website Marketing
Get your website noticed and get results.
Design Portfolio
Design Portfolio
Result driven design makes your website work 24/7 for your business.

What Our Clients Say

“Your company and its professionalism are proof positive that distance truly does not matter when completing a large project such as this.”
-Julie Hilliger
Malcolm-Eaton Enterprises
Our Clients Love Us - CLICK
Website Financing Options Available

UW Madison Alumni

Webstix in Madison, WI
2820 Walton Commons Ln.
Suite 108
Madison, WI 53718
608-277-7849 608-710-4020
magnifier linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram