Skip to content

You are here: Home / kb / Modifying Your Hosts File

Knowledgebase Guide

Modifying Your Hosts File

If you are moving a website to a new server but want to keep the old website live during testing,
you can modify the hosts file on your own computer. This allows your computer to view the website
from the new server before changing the live DNS records.

Important: Changes to your hosts file only affect your own computer. Other visitors will still see the live website
based on the domain’s public DNS records.

What Does the Hosts File Do?

Normally, your computer uses public DNS to find out which server a domain should load from. By editing your hosts file,
you can override this locally and tell your computer to load a domain from a specific IP address instead.

This is useful when testing a website on a new hosting server before changing the domain nameservers or DNS records.

Example Hosts File Entry

A hosts file entry normally uses this format:

server-ip-address example.com
server-ip-address www.example.com

Replace server-ip-address with the IP address of your hosting server, and replace
example.com with your own domain name.

Tip: Use the server IP address provided in your New Account Information email or by Cheap Host support.
Server IP addresses can vary depending on which server your account is hosted on.

Example Cheap Host Server IPs

If you have been advised to test against one of these servers, your hosts file entries may look like the examples below.

London UK Server
31.132.0.114 example.com
31.132.0.114 www.example.com
Coventry UK Server
185.103.96.26 example.com
185.103.96.26 www.example.com
US Server
199.231.184.209 example.com
199.231.184.209 www.example.com

Please note: The above are examples. Always use the correct IP address for your own hosting account.

Modify the Hosts File on Windows

On Windows, the hosts file needs to be edited with administrator permissions.

  1. Open the Windows Start Menu.
  2. Type Notepad into the search box.
  3. Right-click Notepad.
  4. Select Run as administrator.
  5. In Notepad, go to File and then Open.
  6. Open the hosts file from the path below.
%WinDir%\System32\drivers\etc\hosts

If you cannot see the hosts file, change the file type dropdown in Notepad from Text Documents
to All Files.

Add your custom entries at the bottom of the file. For example:

185.103.96.26 example.com
185.103.96.26 www.example.com
  1. Replace the IP address with your correct server IP.
  2. Replace example.com with your own domain name.
  3. Save the file using File then Save, or press Ctrl + S.

Modify the Hosts File on macOS

On macOS, the hosts file can be edited using Terminal.

  1. Open Terminal.
  2. Run the command below to open the hosts file using Nano.
sudo nano /etc/hosts

You may be asked to enter your Mac password. When typing the password, the characters may not appear on screen.
This is normal.

Add your custom hosts entries at the bottom of the file. For example:

185.103.96.26 example.com
185.103.96.26 www.example.com
  1. Replace the IP address with your correct server IP.
  2. Replace example.com with your own domain name.
  3. Press Control + O to save the file.
  4. Press Enter to confirm.
  5. Press Control + X to exit Nano.

Flush Your DNS Cache

After changing your hosts file, you may also need to clear your local DNS cache so the change takes effect.

Windows

Open Command Prompt as administrator and run:

ipconfig /flushdns

macOS

Open Terminal and run:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

Test the Website

Once the hosts file has been updated, open your browser and visit your domain name.
Your computer should now load the website from the IP address specified in the hosts file.

  • Use a private or incognito window to avoid browser cache issues.
  • Clear your browser cache if the old version still appears.
  • Test both the non-www and www versions of the domain.
  • Remove the hosts file entries when testing is complete.

Remove Hosts File Changes After Testing

Once you have finished testing, remember to remove the custom hosts file entries or comment them out.
Otherwise, your computer may continue loading the website from the test server instead of using live DNS.

To disable an entry without deleting it, you can place a # at the start of the line:

# 185.103.96.26 example.com
# 185.103.96.26 www.example.com

Need Help Testing a Migration?

If you are unsure which server IP to use, or if your website does not load correctly after modifying your hosts file,
please sign in to your hosting account and open a support ticket.


Open Support Ticket