How to Test a New Host Before Changing DNS with the Hosts File
- A. MounesiAuthor
- Release Date
- 5 minutesReading time
- 4Views
- A. Mounesi
- Published:
- 5 min read
- 4 views
You’ve moved your site to a new host and everything looks ready, but you’re still nervous about changing the domain’s DNS: if something doesn’t work on the new host, visitors land on a broken site. The good news is that you don’t have to switch DNS blindly. With one simple trick you open the new site under its real domain, on your own computer only, and test everything.
In this guide you’ll test a new host before changing DNS with the hosts file, step by step: you find the new host’s IP, edit the Windows hosts file, check that the page really comes from the new host and put everything back to normal after the test.
Short answer: take the new host’s IP from cPanel, open Notepad with Run as administrator and add a line like “IP domain www.domain” to C:\Windows\System32\drivers\etc\hosts. Now only your computer opens the domain on the new host, while the rest of the world still sees the old site. After the test, delete that line.
How does the hosts file do this?
DNS tells everyone which IP your domain is on. The hosts file is a local list on your own computer that is read before DNS: if you write the domain name with the new host’s IP in it, only that computer goes to the new host and visitors see no change at all.

1. Find the new host’s IP
Log in to the new host’s cPanel (if you don’t know the address, see How to Log In to cPanel). In the General Information column, copy the Shared IP Address or Dedicated IP Address. You’ll also find this IP in the host’s welcome email.
In the Domains section, also check that the domain is set up on this host and that its Document Root points to the folder where you put the site.
2. Edit the Windows hosts file
- Type Notepad in the Start menu, right-click it and choose Run as administrator.
- Under File → Open, type this path in the File name box and click Open: C:\Windows\System32\drivers\etc\hosts
- At the end of the file, add a line like this one, with the new host’s IP in place of the sample IP and your own domain in place of example.com:
203.0.113.25 example.com www.example.comSave the file with File → Save; its name must stay hosts, with no .txt extension. A hosts line holds only the IP and the names, no http and no path. On a Mac or Linux, add the same line to the file with sudo nano /etc/hosts.
If you have Microsoft PowerToys, its Hosts File Editor does the same job without Notepad: click New entry, type the IP in Address and the domain in Hosts, turn Active on and click Add.

3. Check that the page comes from the new host
Run ipconfig /flushdns in Command Prompt, close the browser completely and open the site in a private window. To be sure, press F12, reload the page with the Network tab open, click the first row and check that the Remote Address under Headers is the new host’s IP.

Now browse the site like a visitor: the home page, a few inner pages, the images, the contact form and the dashboard login. In a shop, test the cart up to the payment step. If you see a database connection error, see How to Fix “Error Establishing a Database Connection” in WordPress.
About HTTPS
Free AutoSSL and Let’s Encrypt certificates are usually issued once the domain’s DNS points to the new server, so before the DNS change the browser may show a certificate warning on the new host. That’s normal, but don’t type passwords or sensitive data on the warning page. If you want to test HTTPS before the switch as well, ask the new host’s support.
A faster way for developers
If you only want to see what the new host answers for one address, without touching the hosts file, use curl in PowerShell or a terminal:
curl.exe -I --resolve example.com:443:203.0.113.25 https://example.com/The –resolve option sends the domain to the new host’s IP for this one request only and shows the response headers.
4. Delete the hosts line after the test
Don’t forget this step! Delete the line you added and save the file, or remove the PowerToys entry, then run ipconfig /flushdns again. If the line stays, then later, when you move the site or the IP changes, your computer goes to the old IP and you spend hours chasing a problem nobody else has.
Once you’ve seen that the site works on the new host, lower the records’ TTL, change the DNS and keep the old host for a few days until the change reaches everyone.
FAQ
Does changing the hosts file affect the site’s visitors?
No. The file only affects the computer you edited it on; everyone else opens the site from the IP that DNS gives.
I saved the file and still see the old site. Why?
Usually either the file wasn’t saved because Notepad wasn’t running as administrator, or the browser kept the old answer. Open Notepad with Run as administrator, check the spelling of the domain, run ipconfig /flushdns and in Chrome also click Clear host cache at chrome://net-internals/#dns.
Free site transfer to HiData
Moving your site from another host to HiData’s hosting is free, and our team does it without downtime; you just use this method to test the site on the new host before changing DNS. If you’re bringing the site over from DirectAdmin yourself, see Moving a DirectAdmin Backup to cPanel and pick your host from our professional cPanel hosting!


