Testing a migrated site before you change the DNS (the hosts file)

To see the new site before the DNS changes, add one line to your computer’s hosts file saying “this domain lives at this IP address”. Only your computer goes to the new server; the rest of the world stays on the old one. When the test is over, you remove the line.

Step by step

1 Find the new server’s IP. It is in the new account’s cPanel. See your hosting IP address and where to find it.
2 Open the hosts file with administrator rights. On Windows it is C:\Windows\System32\drivers\etc\hosts (open Notepad as administrator). On macOS and Linux it is /etc/hosts (open it with sudo in an editor).
3 Add a line at the end, with the IP, the domain and the www variant (the address is only an example: swap it for the IP from step 1, and the name for your domain):203.0.113.10 yourdomain.tld www.yourdomain.tld
4 Save, and clear the computer’s DNS cache. On Windows, ipconfig /flushdns at a command prompt. On macOS and Linux the method varies with the system; if you are not sure, restarting the computer does the same.
5 Close every browser window and open a new one, preferably private. If a VPN, a proxy or the browser’s “secure DNS” is on, switch it off: they may ignore the file.
6 Walk through the site with the list below.
7 Delete the line from the hosts file when you finish. If you leave it, your computer stays stuck on the old IP even after the DNS changes.

What to test

Test What to look for
Home page and inner pages They load without errors, with the images and the style.
Login It signs in and keeps the session.
Forms and sending e-mail The message arrives. See sending e-mail from PHP.
Search and internal links They do not lead to the old domain.
PHP version and errors No new message in the log. See the PHP error log.

If you have a command line you can look at just the responses, without the browser, by forcing the IP: curl -I --resolve yourdomain.tld:80:IP http://yourdomain.tld/.

https may warn about the certificate. The free certificate on the new account is only issued after the domain points to it, so until then the browser may show a warning. It is expected, and does not mean the site is broken. If you test with curl, add -k to the command to ignore the warning.
Do not make real changes during the test. An order, a comment or a sign-up made on the new site while the public still sees the old one ends up in one place only and is lost when the DNS changes.
E-mail is not tested this way. The hosts file only touches the site’s name; mailboxes depend on other DNS records. To see the site without touching anything on your computer there is also the temporary address: seeing the site before the domain points here.

Did everything and the site still opens the old one? Tell us the domain and the line you added to hosts.

Open a support ticket

SEE ALSO

Seeing the site before the domain points here, and the Index of / listing

What your hosting IP address is and where to find it

Moving a site by hand: files by FTP and the database

Pointing your domain to us: nameservers, step by step

RECOMMENDED PRODUCT

Register your .com domain

Secure your company name before someone else registers it. from ₦25.500,00/yr

Search a domain
  • 0 Users Found This Useful
Was this answer helpful?