Move a website to a new host without downtime: the hosts file method
How we move a live website to new hosting with no downtime: copy it across, test it on the new server through your hosts file, then update the DNS A record.
- Published
- Written by
- Md Alamgir Hossen
- Reading time
- 16 min read
- Filed under
- White-label development

Your hosting has become slow, support takes days to reply, and the renewal price keeps going up. You want to move a website to a new host without downtime, but the site is live. Customers are filling in forms, orders are coming in, and nobody wants a “this site can’t be reached” page, even for an hour.
We move live websites to new hosting for agencies, under their brand, and for business owners direct. The method never changes. We build the site on the new server while the old one keeps running. We check it from our own computer through the hosts file. Only then do we point the domain’s A record at the new IP address. Visitors never see the move. This post is that method, step by step.
Quick answer: don’t cancel your old hosting. Lower the TTL on your DNS records a day or more ahead. Copy the files and database to the new hosting. Add the new server’s IP address to the hosts file on your computer, so only you see the new copy, and test everything there, SSL included. Do a final sync of anything that changed, then update the A record to the new IP. Remove the hosts entry, watch the traffic move across, and cancel the old hosting only when its traffic has stopped.

Six steps, always in this order. The old hosting stays live until the last one.
Why moving to new hosting causes downtime
Downtime during a hosting move rarely comes from the copy itself. It comes from doing things in the wrong order. The domain gets pointed at a new server that isn’t ready. The old hosting is cancelled while some visitors are still being sent there. Or the new server has no SSL certificate, and visitors get a security warning instead of the site.
- DNS changes are not instant. Every DNS record has a TTL (time to live) that controls how long it is cached, as Cloudflare’s DNS documentation explains. Until that time runs out, some visitors are still sent to the old IP address.
- Google expects the two servers to overlap. Google’s guide to changing hosting without changing URLs says to keep the old hosting running until its traffic reaches zero.
- Your own computer can skip DNS. The hosts file on your computer takes priority over DNS lookups, as Akamai’s Linode guide explains. That is what lets you test the new server before anyone else sees it.
Put those three facts together and you have the whole method. Both servers run side by side, you test the new one privately, and DNS moves visitors across without a gap.
Before you start: what you need
To move a website to a new host without downtime, gather these six things first. Most take a few minutes, and each one closes a gap that could take the site down later.
| What you need | Where to find it | Why it matters |
|---|---|---|
| The new server’s IP address | The new host’s welcome email or control panel | It goes in your hosts file now and in the A record later |
| Access to where your DNS is managed | Check the domain’s nameservers: your registrar, Cloudflare or the old host | This is where you change the A record |
| A copy of every DNS record | Export or screenshot the DNS zone | Email and verification records survive the move |
| A full backup | Files and database from the old hosting, kept off that server | Your way back if anything goes wrong |
| Where your email is hosted | Your MX records | Tells you whether email has to move too |
| The old server’s settings | PHP version, memory limit, upload size | Match them on the new server so nothing breaks |
Step 1: find out where your DNS lives, then lower the TTL
Look up your domain’s nameservers first. They tell you who answers DNS questions for your domain, and that is where your A record lives. If they point at your registrar or at Cloudflare, you’re in good shape. Your DNS keeps working after the old hosting is gone.
If the nameservers belong to your old hosting company, be careful. Your DNS zone lives on their servers. When you cancel the account, your DNS records can disappear with it, email records included. Copy every record to your registrar’s DNS or to Cloudflare, and switch the nameservers well before you cancel.
Then lower the TTL on the A records for your root domain (@) and www. We set them to 300 seconds, which is five minutes. Do it early: Google suggests lowering the TTL at least a week before the move. The shorter TTL only takes over once copies cached under the old one have expired. So a record with a TTL of 86,400 seconds needs a full day before it starts moving fast.
If your domain uses Cloudflare, DNS-only records can go as low as 60 seconds. Proxied records, the ones with the orange cloud, are fixed at 300 seconds.
Step 2: copy the website to the new hosting, and keep the old one running
Don’t cancel the old hosting, and don’t tell the old host you’re leaving yet. Some providers close the account on the day you ask. The old server is the site your visitors use until the very end.
Add your domain to the new hosting account first, so the new server knows to answer for it. Then copy the files and the database across. For a WordPress site that keeps the same domain, this is simpler than most people expect. WordPress’s own guide says that if the database and URL stay the same, you can move the site by copying the files and the database. There is no search and replace to run.
We move the database with WP-CLI, which exports and imports it with one command each:
# on the old server
wp db export site.sql
# on the new server, after copying site.sql across
wp db import site.sql
No command line? Most control panels and migration plugins do the same copy, and the rest of this method works whichever tool you use.
If the new database has a different name, user or password, update them in wp-config.php. Then match the server settings from your list: the same PHP version, memory limit and upload size. WP Engine’s migration guide names mismatched server settings as the cause of most fatal errors during a move, so this check is worth the five minutes.
Step 3: point your own computer at the new server with the hosts file
This is the heart of a hosting move without downtime. Right now, your domain still points at the old server. To see the new copy at the real address, you edit the hosts file on your own computer. It is a small text file that maps domain names to IP addresses, and your computer checks it before it asks DNS. Add one line for the domain and one for www, and only your computer goes to the new server. Everyone else carries on as normal.

In the examples below, 203.0.113.25 stands for your new server’s IP address. Swap in the real one.
On Windows
- Open the Start menu, type Notepad, right-click it and choose Run as administrator.
- Go to File → Open and browse to
C:\Windows\System32\drivers\etc. Change the file type from Text documents to All files, then openhosts. - Add these two lines at the bottom and save.
203.0.113.25 example.com
203.0.113.25 www.example.com
Then open Command Prompt as administrator and clear the DNS cache:
ipconfig /flushdns
On macOS
sudo nano /etc/hosts
# add the two lines, save with Control+O, then exit with Control+X
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
On Linux
sudo nano /etc/hosts
# add the two lines and save
sudo resolvectl flush-caches # on systems that use systemd-resolved
Browsers keep their own cache too. Close and reopen the browser, or in Chrome go to chrome://net-internals/#dns and click Clear host cache.
Step 4: prove you’re on the new server, then test everything
Before you test anything, make sure you really are looking at the new server. It is easy to spend an hour checking the old site by mistake. Three quick checks help:
- Run
ping example.com. It shows the IP address your computer is using, and it reads the hosts file. It should show the new IP. The server may not answer the ping, but the IP in the first line is what matters. - Don’t use
nslookupordigfor this. They ask DNS servers directly and skip the hosts file, so they still show the old IP. That is expected, and it becomes useful in step 7. - Use a marker file. Upload a small file such as
new-server.txtto the new hosting only, then openexample.com/new-server.txt. If it loads, you’re on the new server. Delete it when you’re done.
Test the site as if it were launch day
This is the step that makes a hosting move safe, because you find problems while the public still uses the old server.
| Area | What we check | How we check it |
|---|---|---|
| Pages and media | Home page, key pages, images and downloads | Click through the menus and the pages that bring in traffic |
| Forms and email | Every form sends, and the email arrives | Real test submissions to a test inbox |
| Logins | WordPress admin, customer and member accounts | Log in and out with a test account |
| Online shops | Cart, checkout, payments and order emails | A test order in test mode, then switch payments back to live |
| SSL | The padlock shows, with no warning | Open the https address in your browser |
| Links | No 404 pages on posts or products | If you see 404s, re-save Settings → Permalinks |
| Scheduled tasks | Backups, emails and syncs that run on a timer | Check WP-Cron or the server’s cron jobs |
| Search settings | Search engines are allowed in | Discourage search engines is unticked, and robots.txt doesn’t block the site |
Checking all of this by hand takes time. FlyLive, our AI launch checklist for WordPress, can check forms, SEO, speed, security and legal pages on the new copy while you preview it, and it explains each problem in plain words.
Sort out SSL before you switch
SSL is where many “zero downtime” moves go wrong. Free Let’s Encrypt certificates are usually issued with the HTTP-01 check, which needs your domain to load a file from the new server. Before the DNS switch, it can’t, so the new host often can’t issue the certificate yet, and your preview shows a security warning.
There are two clean ways round it. Ask the new host to issue the certificate with DNS validation, which Let’s Encrypt supports even for servers that aren’t public yet. Or install a copy of your current certificate on the new server. Our rule is simple: don’t switch DNS until the https address loads in your preview without a warning.
Step 5: freeze changes and do a final sync
Your copy is a snapshot. Anything that happened on the old site after you copied it, such as new orders, form entries, comments, sign-ups or blog posts, exists only in the old database. If you switch without dealing with it, it’s lost.
For a brochure site, this is easy. Ask everyone not to edit the site on the day, and copy the database again just before the switch. For a shop or membership site, pick the quietest hour you have. Pause checkout and sign-ups for a few minutes, export the database once more, import it on the new server, then make the switch. That short pause is the only moment a visitor could notice anything, and it protects every order.
Step 6: update the DNS A record to the new IP
Log in where your DNS is managed and change the A record for your root domain, shown as @ or your bare domain, to the new server’s IP address. Then check www. If it has its own A record, change that too. If it is a CNAME that points at your root domain, leave it alone, because it follows the root automatically.

Two kinds of record catch people out:
- AAAA records. These are the IPv6 version of an A record. If your old host set one up, visitors on IPv6 networks keep going to the old server. Point it at the new server’s IPv6 address, or delete it if the new host doesn’t give you one.
- Email records. Leave MX, the mail A record and your SPF, DKIM and DMARC TXT records alone unless your email is moving too. If WordPress sends email straight from the new server, add the server to your SPF record, or better, send through an SMTP service.
Behind Cloudflare with the orange cloud on? Change the same A record in Cloudflare. Visitors keep seeing Cloudflare’s own addresses, so the switch shows up quickly.
Step 7: remove the hosts entry and watch the switch
Now delete the two lines from your hosts file, or put a # at the start of each, and clear your DNS cache again. Akamai’s guide gives the same advice once testing is done. If you forget, your computer keeps showing the new server even if the public DNS is wrong, and you’ll be the last person to find out.
Then check what the rest of the world sees:
nslookup example.com 8.8.8.8
dig +short example.com @1.1.1.1
Both should return the new IP. A global DNS checker shows the same from many countries at once. Google’s hosting-move guide also suggests watching the server logs on both servers: traffic should fall on the old one and rise on the new one. Once visitors arrive, clear your caching plugin and any CDN cache on the new server. Our guide to website caching explains the layers.
Keep an eye on Google Search Console for the next few days. Google says Googlebot may crawl less for a short time after a hosting move, then recover, as long as the new server has no serious problems. Check that your Search Console verification file or meta tag came across with the site, too.
Step 8: cancel the old hosting last
Only cancel the old hosting when three things are true. Its server logs show no more visitors, because Google’s guide says to wait until the traffic to the old provider reaches zero. Your DNS no longer depends on it. And your email has a new home, if it lived there.
Before you close the account, download one last full backup, mailboxes included, and keep it somewhere safe. Then ask the old host to delete your data.
If something goes wrong after the switch
This is why the old hosting stays live, and it is the real reason you can move a website to a new host without downtime: there is always a way back. Point the A record back at the old IP address. With a TTL of 300 seconds, most visitors are back on the old server within minutes, and you can fix the new one in peace. Copy back any orders or form entries the new server took in the meantime, test again through the hosts file, then switch once more.
Privacy rules to check when you change hosting
- Your host handles personal data for you. Form entries, orders and user accounts all live on the server. The UK ICO says you need a written contract with any processor that handles personal data on your behalf. Most hosts call this a data processing agreement.
- Know where the new server is. Check which country your data will be stored in, and update your privacy policy if it names your hosting company or the location.
- Move backups safely. A database export holds customer data. Don’t send it by email, and don’t leave
site.sqlin the website’s public folder, where anyone who guesses the name can download it. Delete the copies once the move is done. - Close the old account properly. That same contract should require the old host to delete or return your data when the service ends. Ask them to confirm the deletion in writing.
Frequently asked questions
Can I move my website to a new host without downtime?
Yes. Keep the old hosting running, copy the site to the new host, test it through your hosts file, then update the DNS A record. While DNS updates, some visitors reach the old server and some reach the new one, and both work. Cancel the old hosting only when its traffic stops.
How long does DNS take to update after I change the A record?
It depends on the record’s TTL. With a TTL of 300 seconds, most visitors see the new server within minutes. With 86,400 seconds, it can take up to a day. That is why you lower the TTL well before the move.
Should I change the nameservers or just the A record?
If your DNS is already at your registrar or Cloudflare, change only the A record. It is quicker, and it leaves email untouched. Change nameservers only when your DNS lives with the old host, and copy every record across first.
Will changing hosting affect my SEO?
Not if the URLs stay the same and the new server works well. Google says Googlebot may crawl less for a short time after a hosting move, then recover. If the domain or URLs change as well, you also need redirects. Our guide on whether a domain change hurts SEO covers that.
Will I lose my email when I change hosting?
Only if your email lives with the old host and you cancel it before moving the mailboxes. Changing your website’s A record doesn’t touch your MX records. Decide where email will live before you cancel anything.
How do I test my website on the new host before changing DNS?
Add the new server’s IP address and your domain to the hosts file on your computer, then clear your DNS cache. Your browser loads the site from the new server, while everyone else still sees the old one. Remove the entry when you’re done.
Want your hosting move done for you?
We move WordPress, WooCommerce and custom websites to new hosting with the old site live the whole time, and with email and rankings intact. Agencies can send us the work under their own brand. Business owners can hire us direct.
- Want us to handle it? See our website migration service.
- Launching a new site instead? Use our website go-live checklist.
- Want it looked after on the new hosting? Read about website maintenance.
- Ready to start? Send us your project.
Sources
- Google Search Central, Site moves without URL changes
- WordPress, Moving WordPress
- Akamai (Linode), Previewing websites without DNS
- Cloudflare, Time to Live (TTL)
- Let’s Encrypt, Challenge types
- WP Engine, The developer’s guide to zero-downtime website migrations
- ICO, Contracts between controllers and processors


Comments
No comments yet. Yours would be the first.
Leave a comment
Your email is not published. Comments are read before they appear, so give it a few hours.