Skip to content

Test a website before changing DNS: hosts file vs a preview link

Updated 6 min readBy the DNSPeek team

You can test a site on a new server before DNS changes in two ways: map the domain to the new IP in your computer’s hosts file, or open a preview link that requests the site from the new IP for you. The hosts file is exact and free but works only on the machine you edit, while a preview link works on any device and can be shared with a client. Many teams use both: a preview link for review and sign-off, the hosts file for a final check of things a proxy changes.

Why you can’t just open the new server’s IP

A web server often hosts many sites on one IP address and picks the site by the domain name the browser sends. Open http://203.0.113.10/ and you usually get a default page, a different site, or a certificate warning. To see your site, the request has to go to the new IP while still saying “I want example.com”. Both methods below do exactly that.

Method 1: the hosts file

The hosts file is a small text file that your operating system reads before asking DNS. A line in it overrides DNS for that name on that computer:

hosts file
# Windows: C:\Windows\System32\drivers\etc\hosts  (edit as Administrator)
# macOS / Linux: /etc/hosts  (edit with sudo)
203.0.113.10   example.com
203.0.113.10   www.example.com

The hosts file generator writes these lines for your domain and IP, with steps for Windows, macOS and Linux. It runs entirely in your browser.

  • Exact. The browser talks to the new server directly, with your real domain, its own certificate and headers. Nothing in between changes the response.
  • Works for anything. Private IPs, intranet servers, every subdomain and every port.
  • One machine only. Each teammate or client has to edit their own file, with admin rights.
  • Hard on phones. iOS and Android have no hosts file you can easily edit.
  • Easy to forget. Browsers and the OS cache DNS, so it is easy to look at the wrong server without noticing, and an entry left behind breaks the site for you after the migration.

Side by side

Hosts file compared with a preview link
ItemHosts filePreview link
Who can see the new siteOnly the person who edited the fileAnyone you send the link to
Phones and tabletsImpracticalYes
SetupAdmin rights, a text editor, cache flushingDomain and IP in a form
Response exactly as after the switchYesNearly: security headers and cookie flags are adjusted
Private or internal IPsYesNo, public IPs only
Third-party sign-in and paymentsWork as after the switchReturn to the live domain
Cleanup after the migrationRemove the lines by handDisable the link or let it expire
CostFreeFree plan available

Which one to use when

  • Developer checking their own work on a private server: hosts file.
  • Client, manager or colleague needs to see it: preview link. Nobody outside IT should be asked to edit system files.
  • Mobile layout and real-device checks: preview link.
  • Final check of HSTS, CSP and sign-in flows before the switch: hosts file on your own machine.
  • Agency or host sending many previews: preview links, ideally prefilled from your own system with a /new?domain=…&ip=… link or created through the API.

Whichever you choose, the rest of the move is the same: see the website migration checklist. More on the trade-off: the hosts file alternative, and how DNSPeek compares with SkipDNS, Peek-DNS and hosts.click.

Test the new server either way

  1. Step 1: Find the new server’s public IP

    Take it from the new host’s welcome email or control panel, not from a DNS lookup of your domain, which returns the old server. See Find your server IP.

  2. Step 2: Confirm the server answers for your domain

    Run curl -skI --resolve example.com:443:203.0.113.10 https://example.com/. A 200 or a redirect to your own domain is a good sign; a default page means the site is not set up there yet.

  3. Step 3: Create a preview link to share

    Enter the domain and the IP on the new preview form. Open the link, click through the site and send it to anyone who needs to review it.

  4. Step 4: Add a hosts entry for your own final check

    Generate the lines with the hosts file generator, add them, flush the DNS cache and check the parts a proxy changes, such as sign-in and security headers.

  5. Step 5: Remove the hosts entry after the switch

    Delete the lines once DNS points at the new server, so your computer follows public DNS again.

What to check, whichever method you use

Pre-switch test

  • The site, not a default page, loads from the new IP
  • Home page, key pages and navigation work
  • Forms submit and confirmation emails arrive
  • Login to the CMS or admin area works
  • Images, fonts and scripts load without errors
  • Mobile layout checked on a real phone
  • HTTPS plan clear: certificate now or right after the switch
  • Hosts file entries removed after the switch

Frequently asked questions

Is a preview link safe to send to a client?

Yes, with a little care. Anyone with the link can open it, so set a password for anything sensitive and switch the link off when the migration is done. Remember that actions on the preview, such as orders or form submissions, really happen on the new server.

Can I edit the hosts file on an iPhone or Android phone?

Not without jailbreaking or rooting the device, or routing it through a VPN or proxy app that rewrites DNS. That is why preview links are the practical way to check a new server on a phone.

Why do I still see the old site after editing the hosts file?

The browser or operating system cached the old DNS answer, or the browser uses DNS over HTTPS and ignores the hosts file. Flush the DNS cache, restart the browser, and check that both the bare domain and www are in the file.

Does a preview link show exactly what visitors will see?

Almost. The pages, files and redirects come from the new server, but the proxy removes some security headers and adjusts cookies so the preview works on its own address, and third-party sign-in returns to the live domain. Check those on the real domain after the switch.

Do I need an account to create a preview link?

No. You can create a guest preview link on DNSPeek with just a domain and an IP. Guest links are limited; a free account adds a password, spaces and a QA report.

Moving a site? Use the migration checklist

Every step from lowering the TTL to checking email after the switch, on one printable page. With a free account you keep your preview links in one place and run a QA report of the site on the new server.

Check the new server before you switch

DNSPeek gives you one HTTPS link that shows your site from the new server while DNS still points at the old one. Open it on any device, share it with your team or client, and run a QA crawl on the same link.

Create a free preview link