How to Verify Your Site Works on the New Host Before Switching DNS

To test a site on new host before the DNS switch, point your own machine at the new server's IP and exercise every function the site depends on while the old host keeps serving real visitors. The trick is that HTTP, TLS, mail and redirects all key off hostnames, so you need to override name resolution locally rather than change public records.

Nothing about this process is exotic. It is a sequence of controlled lies told to your own client: the wrong IP for a hostname, the wrong port for a service, the wrong certificate for a name. Each lie is temporary, reversible, and invisible to anyone but you.

Step one: resolve the name to the new host without touching DNS

Start with the cheapest override you have, the hosts file. On Linux and macOS it lives at /etc/hosts, on Windows at C:\Windows\System32\drivers\etc\hosts. Add a line mapping the public hostname to the new server's IP. From that moment every browser, curl and test runner on the machine resolves that name to the new box, while the rest of the internet still sees the old one.

If you would rather not edit system files, or you need to test several hostnames at once, use curl's --resolve flag. It pins a single name to an address for one invocation, which is ideal for scripted checks:

$ curl -sS -o /dev/null -w '%{http_code} %{remote_ip}\n' \
    --resolve www.example.com:443:203.0.113.10 \
    https://www.example.com/
200 203.0.113.10

The %{remote_ip} variable is the important part. It proves the request actually landed on the new address rather than a stale connection or a cached answer. Run the same command without --resolve and you should see the old IP, which confirms your override is doing the work.

For anything involving more than HTTP, or for a browser, the hosts file is the better tool because it applies to every process on the machine. Remember to remove the line afterwards. A forgotten hosts entry is a classic cause of "the site is down" reports that only affect one person.

Step two: check TLS, the Host header and the response body

Certificates are the first thing that breaks in a migration. The new server may be serving a self signed certificate, an expired one, or the wrong name entirely, and none of that is visible until you look. Inspect the chain and the subject explicitly:

$ echo | openssl s_client -connect 203.0.113.10:443 \
    -servername www.example.com 2>/dev/null \
    | openssl x509 -noout -subject -issuer -dates
subject=CN = www.example.com
issuer=C = US, O = Example CA, CN = Example Intermediate
notBefore=...
notAfter=...

The -servername flag matters because it sends the TLS SNI extension, which is how the new server knows which certificate to present. Omit it and you will often get the default vhost's certificate, which tells you nothing useful. If the subject does not match the hostname, or the dates are wrong, stop here. Fix the certificate before you test anything else, because every HTTPS check downstream depends on it.

Next, confirm the application sees the right hostname. Virtual hosts, framework routing and generated absolute URLs all depend on the Host header, so send it deliberately and read what comes back:

$ curl -sSI --resolve www.example.com:443:203.0.113.10 \
    https://www.example.com/ | head -n 5
HTTP/2 200
server: nginx
content-type: text/html; charset=UTF-8
strict-transport-security: max-age=31536000
x-cache: MISS

Look for a Location header that points at an internal hostname or a staging domain. That is the single most common leftover from a migration, and it will send real users to a dead end once DNS moves. Also check that Content-Length or the body itself looks like the real page and not a default welcome screen.

Step three: verify the database and dynamic paths

A static homepage proves very little. The site works only if the database connection, the session store and the write path all work on the new host. Pull one page that must query the database, then confirm the data is the current data and not a stale dump. Compare a record count or a recent timestamp against the source:

$ mysql -h 203.0.113.10 -u app -p -e \
    "SELECT COUNT(*), MAX(created_at) FROM posts;" appdb
COUNT(*)  MAX(created_at)
   18422  2024-05-11 09:14:02

If those numbers match the old host, the dump restored cleanly. If they are lower, you restored an older backup and the cutover will silently roll the site back. Do not skip this check. It is the difference between a migration and a data loss incident.

Then exercise the write path, because read only checks hide permission problems. Log in, post a comment, upload a file, trigger a password reset. Watch the application log on the new server while you do it. A successful write that appears in the log with no errors is worth more than any number of green health checks.

For WordPress and similar applications, also confirm the site URL setting. If the database still contains the old staging address, every generated link will point there. Search the dump for the old hostname before you restore it, and rewrite it in a single pass rather than clicking through admin screens.

Step four: test redirects, mail and the corners

Redirects are where migrations quietly break search rankings and user bookmarks. Test the http to https hop, the www to apex hop, and any legacy paths you maintain. Follow the chain and count the hops:

$ curl -sSIL --resolve example.com:80:203.0.113.10 \
    http://example.com/old-page | grep -iE '^(HTTP|location)'
HTTP/1.1 301 Moved Permanently
Location: https://www.example.com/new-page
HTTP/2 200

One hop is fine. Three or more is a chain you should collapse. Check that the final status is 200 and not 404, and that the destination is the page you expect.

Mail is the part people forget, and it is the part that causes the most damage after cutover. Outbound mail from the new host must pass SPF, DKIM and DMARC, or your transactional mail will land in spam. Send a test message through the new server's submission port and read the headers of what arrives:

$ swaks --to [email protected] --from [email protected] \
    --server 203.0.113.10:587 --tls --auth LOGIN
...
<< 250 2.0.0 Ok: queued as 4F2A1C

Then open the received message and confirm the Authentication-Results header shows spf=pass and dkim=pass. If either fails, the DNS records for the new sending infrastructure are wrong, and you need to fix them before you move the MX records. Inbound mail is separate: test that the new host accepts mail for your domains on port 25 and that the mailbox exists, but do not change MX until the outbound side is clean.

Finally, walk the corners. Check the 404 page, the robots file, the sitemap, any API endpoints the front end calls, and the asset paths for CSS and JavaScript. A page can render while every image 404s behind it. Open the browser developer tools network panel and look for red rows.

What to do next

Write the checks down as a script you can run again after the cutover, with the --resolve flags removed. Run it against the new host first, then flip DNS, then run it again against the public name. Lower the TTL on your records a day or two before the switch so the change propagates quickly, and keep the old host online and serving until the script passes cleanly. If anything fails after the flip, you can point the records back while you investigate.

Related articles

Subscribe to our newsletter

Get the latest hosting tips, performance insights, and industry news.