Skip to content
Host4u Limited

Previewing a site before DNS changes (hosts file)

Support Portal  »  Knowledgebase  »  Viewing Article
There was a problem loading the comments.
  Print
  • 13/11/2026 10:42 am

When you move a website to a new server, you can look at it on the new server before you change the domain's DNS, so you can test it first. You do this by editing the hosts file on your own computer, which tells only your computer where the domain lives.

What you need

The server's IP address. In cPanel it is shown as Shared IP Address on the home page, under General Information, or it is in your welcome email.

Mac and Linux

  1. Open /etc/hosts in a text editor, with administrator rights.
  2. Add a line at the end with the IP address, then the domain name and its www version, for example 203.0.113.10 example.com www.example.com.
  3. Save the file and reload the website in your browser (you may need to restart it).

Windows

  1. Open Notepad as administrator.
  2. Open C:\Windows\System32\drivers\etc\hosts.
  3. Add the same line at the end, save, and reload the site in your browser.

Afterwards

  • Remove the line when you have finished testing. Your computer keeps using it until you do, so you would not see the real website, or later changes, from there.
  • Only your computer is affected. Other people still see the old site until the DNS is changed: see Pointing your domain at your hosting.

A temporary address

Some hosting also offers a temporary address in the form http://IP/~username. It does not work for every website, which is why the hosts file is the more reliable test.


Share via
Did you find this article useful?  

Related Articles


Self-Hosted Help Desk Software by SupportPal