Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to Use the Hosts File

This guide shows how to use the hosts file on your computer to see your website before the domain points to it.

Domains and DNS2 min read16 steps

What is a hosts file?

A hosts file is a small text file on your computer. It is like your own private address book. It tells your computer which IP address to use for a website name. An IP address is a number that identifies a computer on the internet.

Normally your computer asks DNS for this. DNS is the internet's phone book. The hosts file is checked first. This means you can test a new website on a new server before you change the real DNS. Only your computer is affected. Nobody else sees the change.

What you need

You need the server IP address. It is in your welcome email. You can also ask Hostvento support.

Warning: Editing the hosts file wrongly can stop sites from loading on your computer. Make a copy of the file first.

Steps on Windows

  1. Click the Start menu and type Notepad.
  2. Right-click Notepad and choose Run as administrator.
  3. Click File, then Open.
  4. Go to C:\Windows\System32\drivers\etc.
  5. Change the file type box to All Files.
  6. Open the file named hosts.
  7. At the bottom, add a new line.
    203.0.113.10 example.com www.example.com
    Use your real server IP and your domain. The example IP here is only a sample.
  8. Save the file.

Steps on Mac or Linux

  1. Open the Terminal app.
  2. Type the command below and press Enter.
    sudo nano /etc/hosts
    This opens the hosts file in a text editor with admin rights.
  3. Type your password if asked.
  4. Add the same kind of line at the bottom.
  5. Press Ctrl+O to save, Enter to confirm, then Ctrl+X to exit.

Test and clean up

  1. Close your browser fully and open it again.
  2. Visit your domain. You should see the site on the new server.
  3. When you finish testing, remove the line from the file. Save again.
Tip: A line starting with # is a comment. The computer ignores it. Add one to turn a line off.

Quick recap

  • The hosts file maps a name to an IP on your computer only.
  • Add a line with the server IP and the domain.
  • Edit it as administrator and save.
  • Remove the line when you finish testing.