DNS migrationhosts filehostingSSLtesting

Test a website before DNS migration: method + checklist (2026)

How to test your new server before changing DNS? Hosts file method, SSL verification, complete checklist for zero-downtime migration.

L

Locahl Team

Β·5 min read

Migrating a website to a new server is always stressful. What if something doesn't work? What if the site is inaccessible for hours? The solution: test your new server BEFORE changing DNS, using the hosts file.

Why test before migration?

Risks of direct migration

  • Downtime: If the new server has a problem, your site is down
  • SSL Certificate: Let's Encrypt can fail if misconfigured
  • Server configuration: PHP version, missing modules, .htaccess...
  • Database: Connections, performance, corrupted data
  • Paths and links: Hardcoded URLs, absolute paths

The hosts file advantage

By modifying your hosts file, you point the domain to the new server only on your machine. The rest of the world continues accessing the old server.

Result: you can test for hours without impacting your users.

Simplify your hosts file management

Locahl lets you manage your hosts file visually, without touching the terminal. Automatic DNS flush, multiple environments, and backups included.

Step 1: Get the new server's IP

Connect to your new server/host and note the IP address.

At common hosts

SiteGround / Bluehost

  • cPanel > Server Information > IP Address

Cloudways / DigitalOcean

  • Dashboard > Server > IP Address

AWS / GCP

  • Instance > Public IP

Netlify / Vercel

  • Deploy settings > Domain settings

Step 2: Modify the hosts file

On Mac

sudo nano /etc/hosts

Add at the end:

# Temporary migration - DELETE after migration
203.0.113.50    www.mysite.com
203.0.113.50    mysite.com

Replace 203.0.113.50 with your new server's IP.

On Windows

1. Open Notepad as administrator 2. File > Open > C:\Windows\System32\drivers\etc\hosts 3. Add the same lines

Flush DNS cache

Essential after modification:

# Mac
sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder

# Windows
ipconfig /flushdns
Also readFlush DNS Mac: Commands by macOS Version

Step 3: Tests to perform

Basic test

1. Open your browser in private/incognito mode 2. Go to https://www.mysite.com 3. The site should display from the new server

Verify you're on the right server

Create a temporary test file on the new server:

echo "NEW SERVER" > /var/www/html/test-migration.txt

Then access https://www.mysite.com/test-migration.txt

Don't forget to delete this file afterwards!

Complete test checklist

Pages and navigation

  • [ ] Homepage
  • [ ] Internal pages (at least 5)
  • [ ] Contact forms
  • [ ] Login/signup pages

Features

  • [ ] Internal search
  • [ ] Cart / e-commerce
  • [ ] Member area
  • [ ] API / endpoints

Media

  • [ ] Images display
  • [ ] Videos play
  • [ ] PDFs downloadable
  • [ ] Uploads work

Performance

  • [ ] Acceptable load time
  • [ ] No 500/503 errors
  • [ ] Cache works

Step 4: Verify SSL certificate

This is crucial. A misconfigured certificate = site inaccessible via HTTPS.

Visual verification

  • Green padlock in address bar
  • No security warning

Certificate verification

Click the padlock > Certificate > Verify:

  • Correct domain
  • Validity date
  • Issuer (Let's Encrypt, Sectigo, etc.)

Common SSL problems

"NET::ERR_CERT_COMMON_NAME_INVALID" The certificate isn't issued for this domain. Regenerate it.

"Certificate expired" The certificate wasn't renewed on the new server.

Step 5: Proceed with DNS migration

Once all tests pass:

1. Connect to your registrar (GoDaddy, Namecheap, Cloudflare...) 2. Modify the A records to point to the new IP 3. Wait for propagation (minutes to 48h depending on TTL)

Check propagation

Use whatsmydns.net to see global status.

Step 6: Post-migration cleanup

Remove hosts entries

Once propagation is complete:

sudo nano /etc/hosts

Delete the lines added for migration.

Flush DNS cache one last time

sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder

Verify everything works

Test from another device (phone on cellular) to confirm the new server is responding.

Special cases

Migration with CMS change

If migrating WordPress to another CMS, also test:

  • 301 redirects from old URLs
  • Updated XML sitemap
  • Internal links functional

E-commerce migration

Additional critical points:

  • Payment gateways
  • Webhooks (Stripe, PayPal)
  • Transactional emails
  • Stock and pending orders

Sites with CDN (Cloudflare)

If using Cloudflare: 1. Cloudflare proxy uses its own IPs 2. Test in "DNS only" mode (grey cloud) 3. Re-enable proxy after validation

Automate with Locahl

To easily manage these temporary hosts modifications:

  • Create a "Migrations" group
  • Enable/disable with one click
  • Modification history
  • No risk of syntax errors
Also readHow to edit the hosts file on Mac

Complete migration checklist

Before migration

  • [ ] Full backup of current site
  • [ ] Note new server IP
  • [ ] SSL configured on new server
  • [ ] Current DNS with reduced TTL (300s)

During tests

  • [ ] Hosts file modified
  • [ ] DNS cache flushed
  • [ ] All tests passed
  • [ ] SSL certificate validated

After DNS migration

  • [ ] Propagation verified
  • [ ] Site accessible everywhere
  • [ ] Hosts entries removed
  • [ ] Old server kept 7 days (backup)

Conclusion

Testing before migrating is the key to stress-free migration. The hosts file gives you a perfect test environment, invisible to your users. Take time to verify everything before changing official DNS.

Share this article
Available for macOS

Ready to simplify your workflow?

Stop wasting time with the terminal. Locahl lets you manage your hosts file in a few clicks, with automatic validation and no risk of errors.

  • Intuitive visual interface
  • Automatic DNS flush
  • Multi-environment management
  • Automatic backups
  • JSON Import/Export
Get Locahl - €9.99One-time payment, no subscription

Reader Reviews

4.7β˜…(3 reviews)
Stephen B.
β˜…β˜…β˜…β˜…β˜…

"This method saved me from a failed migration. I was able to identify an SSL certificate issue before switching."

July 30, 2025

Natalie V.
β˜…β˜…β˜…β˜…β˜…

"The checklist at the end is perfect. I now use it for all my client migrations."

September 18, 2025

Oliver M.
β˜…β˜…β˜…β˜…β˜…

"Very useful. Would have liked more details on CDN migrations but otherwise excellent."

December 10, 2025

Frequently Asked Questions

How do I test a website on a new server before changing DNS?

Modify your hosts file to point the domain to the new server's IP. Only you will see the new site, other users will continue accessing the old one.

Do SSL certificates work with the hosts file method?

Yes, if the certificate is correctly installed on the new server. Your browser will verify the certificate normally.

How long before I can remove the hosts entries?

Wait for complete DNS propagation, typically 24-48h. Check with tools like whatsmydns.net before removing entries.

Can I test emails with this method?

Emails aren't affected by the hosts file. They follow MX records in DNS. Test them separately after DNS migration.

What if the site doesn't work on the new server?

That's the advantage of this method: simply remove the hosts entry and flush DNS cache. You instantly return to the old server.

Related Articles

9 min read
hosts filemultiple environmentsproject management

How to Manage Multiple Hosts Files for Different Projects

Learn how to manage different hosts file configurations for dev, staging, and production environments. Switch between project setups, version control hosts configs, and streamline team workflows.

L

Locahl Team