View your site on the new server before DNS updates (hosts file)

Print
  • 0

You can open your website on the TopHost server before the domain's DNS has switched over by adding one line to the hosts file on your computer. That line tells only your own computer which IP address to use for the domain. Visitors are not affected, and you delete the line once DNS has updated.

When this is useful

  • You are moving a site to TopHost and want to check it on the new server before changing the nameservers.
  • You have already changed the nameservers and want to keep working while the change spreads. This usually takes a few hours, sometimes up to 24-48 hours.

Step 1. Find the IP address of your server

Log in to cPanel and look at the General Information column on the right of the home page. The address on the Shared IP Address line is the one your sites use. It is also listed in the hosting activation e-mail. For a VPS, use the IP address of the VPS.

Step 2. Add the line to the hosts file

The line has the IP address first, then the names it applies to, separated by spaces. Write both the bare domain and the www variant:

203.0.113.10   domain.md www.domain.md

Replace 203.0.113.10 with the address from step 1 and domain.md with your domain. Lines that start with # are comments and are ignored.

Windows 10 and Windows 11

  1. Open the Start menu, type Notepad, right-click it and choose Run as administrator.
  2. In Notepad choose File, then Open, and go to C:\Windows\System32\drivers\etc. Set the file type filter to All files, because hosts has no extension, and open it.
  3. Add the line at the end of the file and save. If Windows refuses to save, Notepad was not started as administrator. Some antivirus programs also guard this file and must allow the change.
  4. Open Command Prompt and run ipconfig /flushdns to forget the old address.

macOS

  1. Open the Terminal app and run sudo nano /etc/hosts. Enter your Mac password when asked; nothing appears while you type it.
  2. Add the line at the end. Save with Control+O and Enter, then close with Control+X.
  3. Clear the DNS cache with sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder.

Linux

Edit the file with sudo nano /etc/hosts and add the line. On distributions that use systemd-resolved, clear the cache with resolvectl flush-caches.

Step 3. Open the site and check you are on the new server

  • Close the browser completely and open it again, or use a private window, since browsers keep their own list of addresses.
  • Run ping domain.md in a command window. The IP address in the reply must be the one you wrote in the hosts file.
  • A certificate warning is normal at this stage. The free AutoSSL certificate can only be issued after the public DNS points to our server, so for the test use http:// or accept the warning temporarily.
  • If the browser still shows the old site, check whether it uses secure DNS (DNS over HTTPS) in its privacy settings. In some browsers this setting skips the hosts file, so turn it off for the duration of the test.

Phones and tablets do not let you edit the hosts file easily, so do the check from a computer.

Step 4. Remove the line when DNS has switched

Once the nameservers have changed and the site loads from our server everywhere, delete the line (or put # in front of it) and save the file again. A forgotten line keeps pointing your computer to that IP address: if the address ever changes, you will see an old or broken site while everyone else sees the real one. You can see what the public DNS returns with nslookup domain.md after removing the line.

Questions clients ask

Does the change affect my visitors?

No. The hosts file works only on the computer where you edited it.

Can I test e-mail this way?

Only partly. You can add mail.domain.md to the same line to reach the mailbox from your computer, but messages from other senders keep arriving where the public DNS points until the change is complete.

If the site does not open from the new server even with the hosts line in place, open a ticket, naming the domain and the IP address you tried.

Related articles

Was this answer helpful?

Need help?

Write to us in the chat, by e-mail or open a ticket from your account.

Live chatOpen the chat Call us+373 795-800-80 Write to ussupport@tophost.md
Copyright © 2026 TopHost.MD. All Rights Reserved.