The Website Previewer

DNS Preview Guide

How to Preview Your Website Before DNS Changes

Test your site on the new server before switching DNS records. Verify design, SSL, redirects, and app behavior with a temporary preview URL.

A preview URL lets you open your site on its new server before you change DNS. You enter your domain and the new server's IP address. The tool gives you a temporary link on a random subdomain, such as abc123.hosts.li. Its proxy forwards each request to the IP address you entered and keeps your domain name in the Host header, so the new server answers as if DNS already pointed to it. Your live DNS does not change. Free preview links expire in 10 minutes. The two manual methods are an edit to the hosts file and the curl --resolve option.

This guide covers each method, when to use it, and what to check before you switch DNS. It also links to the step-by-step guides for specific platforms, control panels and alternative tools.

What a preview URL does

Every website is reached through a name, such as www.example.com, and an IP address. DNS maps the name to the IP address. A migration changes that mapping. Until the change reaches the resolvers your visitors use, the old server keeps answering. Testing the new server before the switch means reaching it by the domain name without changing DNS.

A preview URL does this for you:

  1. You give the tool your domain and the IP address of the new server.
  2. The tool creates a temporary subdomain that points to a proxy.
  3. The proxy forwards each request to the IP address you entered, and it keeps your domain name in the Host header.
  4. The new server receives a request for your domain, so it serves the site it would serve after the switch.

The Host header matters. RFC 9110 says that the target URI's authority information "is critical for handling a request", and that a client "MUST generate a Host header field in a request unless it sends that information as an ':authority' pseudo-header field" (RFC 9110, section 7.2). Many web servers use that header to choose which site to serve when several sites share one IP address. A preview that sends the right Host header tests the same server selection that visitors will hit after the switch.

What you need before you start

  • The IP address of the new server, and confirmation that the site is deployed there.
  • The domain name you plan to move, and the list of pages you will check.
  • Access to the site's admin area or database, if you want to test logins and forms.
  • Your planned SSL setup. A preview URL shows the site through the preview path, so it does not prove that the new server will serve a valid certificate for your domain after the switch. The section "Certificates during a migration" covers this.

Method 1: a temporary preview URL

This is the fastest method, and it needs no change on your computer. Open the home page of hosts.click, enter the domain and the destination IP address, and create a preview URL. Open the link in a browser, or send it to a client or a QA tester.

Use this method when:

  • you work on more than one computer, or you need to share the preview with a client;
  • you do not want to change a system file on your computer;
  • you need the same preview for several people at once.

Free links expire in 10 minutes. If you need a link that stays active longer, the Pro plan keeps preview links live for days and costs $5 a month. If your test takes longer than a free link lasts, create a new link and repeat the checks that matter most.

The tool sends your traffic through its proxy. Do not use a preview link for pages that carry data you would not share with a third party. Test the pages that need checking, and keep real customer data out of the test where you can.

Method 2: edit the hosts file

The hosts file maps names to IP addresses on your own computer. The hosts(5) manual describes the format as "IP_address canonical_hostname [aliases...]" with "one line per IP address". An entry such as the one below sends your browser's requests for the domain to the new server, and nothing else changes:

192.0.2.10   www.example.com

Replace 192.0.2.10 with the IP address of your own new server. It is an example address.

The hosts-file method has three practical limits:

  • It works on one computer. Other people and devices still use the live DNS.
  • You must edit a system file, and you must remember to remove the entry after the test. A forgotten entry keeps sending that computer's traffic to the new server after the switch, and that can confuse later debugging.
  • It only changes name resolution. Anything that depends on the public DNS, such as a mail server or a third-party service that checks the domain, still sees the old records.

For a full explanation of the hosts file and how it compares with a preview URL, read hosts.click vs Editing the Hosts File. To generate the entry for a specific domain and IP address, use the hosts file generator.

Hosts file steps by operating system

Windows

  • File: C:\Windows\System32\drivers\etc\hosts (no file extension).
  • Open it with administrator rights: right-click Notepad, select Run as administrator, then open the file.
  • Flush the DNS cache: run ipconfig /flushdns in Command Prompt.

macOS

  • File: /etc/hosts.
  • Open it with administrator rights, for example with sudo in Terminal.
  • Flush the DNS cache: run sudo killall -HUP mDNSResponder in Terminal.

Linux

  • File: /etc/hosts.
  • Open it as root, for example with sudo and a text editor.
  • Flush the DNS cache on systems that run systemd-resolved: run resolvectl flush-caches.

Line format on all three: an IP address, then one or more host names separated by spaces or tabs, for example 203.0.113.5 example.com. Lines that start with # are comments.

Method 3: curl --resolve

If you use a terminal, curl can send a request to a chosen IP address without changing any file. The curl manual describes the option as a way to "provide a custom address for a specific host and port pair", and says "Consider it a sort of /etc/hosts alternative provided on the command line".

curl --resolve www.example.com:443:192.0.2.10 https://www.example.com/

The option sends the request to 192.0.2.10 and keeps www.example.com as the host name in the URL. The command tests one URL at a time. Repeat it for each important page, and add -I to see the response headers only:

curl -I --resolve www.example.com:443:192.0.2.10 https://www.example.com/checkout

Use curl --resolve when you want a scripted check or you need the response headers for a list of URLs. Use a browser when you need to see the page as a visitor does, with scripts, styles and images.

Preview methods compared

QuestionPreview URLHosts filecurl --resolve
Changes files on your computerNoYes, until you revertNo
Works for other people and devicesYes, with the linkNoNo, unless they run the command
Traffic goes through a third partyYes, through the preview proxyNoNo
Link or entry lifetimeFree links: 10 minutes. Pro: longerUntil you remove itOne command
Good for many pages at onceYes, in a browserYes, in a browserYes, in a script

No method is right for every test. A preview URL suits shared review and browser checks. The hosts file suits a single developer who wants the browser to reach the new server directly. curl suits scripted checks and header inspection.

Compare the four methods

Hosts file Browser extension Preview URL VPN or tunnel
Shareable No No Yes No
Mobile No No Yes Partial
Admin access Required No No Required
HTTPS Manual Manual Automatic Manual
SEO tools No No Yes No
Cost Free Free Free (10-minute links); Pro $5/mo for longer links Free

Preview a WordPress site before the DNS change

WordPress stores the site address in its database and often uses it to build links, redirects and image paths. A preview therefore needs more than a working home page. Check the links on each page, the admin login, the media library and any plugin that sends email or redirects users.

The step-by-step guide covers the WordPress checks in order: how to preview a WordPress site on a new server before DNS changes.

Preview on a control panel: cPanel and DirectAdmin

Many migrations run through a hosting control panel. The cPanel and DirectAdmin plugins add a preview step to that workflow, so you do not need to copy the domain and IP address by hand.

If a temporary URL that cPanel gives you stops working, read the cPanel temporary URL alternative guide. It explains what to check when the built-in temporary URL fails and how to preview the site another way.

Preview on a specific hosting provider

Each hosting provider has its own control panel, default settings and SSL steps. The host-specific preview guides list the steps for each provider we cover, with the checks that matter most on that platform.

Alternatives to hosts.click

Other tools also create preview links or change the hosts file for you. Two comparisons on this site describe how hosts.click differs from them:

Pick the tool that fits your workflow. Check each tool's own documentation for its current limits and pricing.

What to check before you switch DNS

Test the new server with the same checks you would run after the switch. Group the checks into technical checks and functional checks.

Technical checks

  • HTTPS. The certificate must be valid for your domain on the new server. A preview shows the site, but it does not install the certificate for you. The section "Certificates during a migration" explains the timing.
  • Redirects. Check that http:// redirects to https://, that the www and non-www versions go to one address, and that old URLs return the status code you expect.
  • Canonical URLs and internal links. Pages should link to the right host. A page that builds its links from a hard-coded old domain sends visitors back to the old server after the switch.
  • Mixed content. A secure page that loads images, scripts or styles over http:// shows a browser warning.
  • Status codes on key routes. Check the home page, the login page, a product or article page, and any page that returns a 404 on purpose.

The server diff tool compares the old and new servers for status codes, headers, redirect chains and response content in one scan. For SSL details, use the SSL checker. The cache checker shows whether the new server sends cache headers similar to the old one.

Functional checks

  • Sign-in and sessions. Log in, log out, and check password reset. A session cookie that is set for the wrong domain can make sign-in fail on the new server.
  • Forms and payments. Send a test form and check each callback URL. Payment providers and webhook services often store the callback address in their settings, so a switch can break them.
  • Static assets and JavaScript. Confirm that scripts, fonts and images load from the paths the page expects.
  • Mobile and desktop. Check the layout at both sizes. A cached old layout on the new server can hide a broken stylesheet.

Check the DNS record before and after the switch

Before you change a record, look at the current TTL. The TTL is the number of seconds a resolver may keep a record before it asks again. RFC 1035 defines the TTL field as "the time interval that the resource record may be cached before the source of the information should again be consulted" (RFC 1035, section 3.2.1). RFC 2181 adds that "the TTL specifies a maximum time to live, not a mandatory time to live" (RFC 2181, section 8). A resolver may therefore drop a record sooner than the TTL says, and it may keep an old answer until the TTL runs out.

A low TTL before a migration lets resolvers pick up the new address sooner. The DNS propagation checker shows how a record is answered from several resolvers around the world, so you can see when most of them return the new address. For the background on how caching works, read what DNS propagation is and why the change takes time to show.

Certificates during a migration

A certificate authority checks control of the domain before it issues a certificate. Let's Encrypt describes its HTTP-01 challenge this way: "The HTTP-01 challenge can only be done on port 80". Its DNS-01 challenge proves control "by putting a specific value in a TXT record under that domain name".

An HTTP-01 check reaches the server that public DNS points to. Until you switch DNS, that server is the old one. So a certificate for the new server may fail to issue during the preview, even though the preview works. Plan the certificate for after the switch, or use DNS-01 if your provider supports it. Either way, check the certificate on the new server with the preview, and check it again on the live domain after the switch.

Limits of a preview

A preview shows how the site behaves through the path you tested. It does not prove that everything works after the switch. Keep these limits in mind:

  • Time limits. Free links expire in 10 minutes. A long test needs a new link or a Pro plan.
  • Third-party path. Browser traffic to a preview URL goes through the preview proxy. The hosts file and curl --resolve send traffic straight to the IP address you entered.
  • Domain-dependent behavior. Some pages build links, redirects or cookie scopes from the domain name. These can differ on a preview URL, so check them on the live domain after the switch.
  • Background jobs and email. A preview does not run your cron jobs, and it does not test inbound mail. Check mail routing with the email DNS checker before the switch.
  • Other DNS records. A preview tests the web path only. Check MX, TXT and other records separately.

Migration steps in order

The checks above fit into one plan. For a general walkthrough of the same steps, read how to preview a website on a new server. For the methods side by side, read how to test a website before DNS propagation.

  1. Deploy the site to the new server, and confirm the IP address.
  2. Lower the TTL on the records you will change, and wait for the old TTL to pass.
  3. Create a preview and run the technical and functional checks.
  4. Fix what the checks find, and repeat the checks on the preview.
  5. Switch the DNS records, then check the live domain.
  6. Keep the old server running until the new address has reached your visitors.

The step-by-step version for a full move is in the guide to moving a website to a new host without downtime. The migration checklist generator builds a plan for your hosts and panels.

Automate the technical checks

Running the technical checks above by hand for every migration gets old fast. The hosts.click server diff tool compares your old and new servers side-by-side: HTTP status, headers, redirect chains, mixed content, body content hashes, response time. One scan, every regression caught before DNS flips.

More free tools for your migration

Sources

Toggle navigation