Moving a website to a new host sounds risky, but downtime during a migration almost always comes from doing the steps in the wrong order. If the new server is fully working before any visitor is sent to it, and the old server keeps running until every visitor has moved over, nobody sees an error page. This guide walks through that order, with the commands and checks that make it work, plus the email mistakes that catch people out most often.
The plan in one minute
- Lower your DNS TTL a day or two in advance.
- Set up the new hosting account and add your domain.
- Copy the files and the database to the new host.
- Fix configuration (database details, URLs, paths).
- Test the site on the new server using your hosts file.
- Issue an SSL certificate.
- Recreate email accounts, or decide where email will live.
- Switch DNS.
- Keep the old host running for at least a few days, then cancel.
The rest of this post covers each step in detail.
Step 1: Lower the DNS TTL in advance
Every DNS record has a TTL (time to live): the number of seconds resolvers around the world may cache the answer before asking again. Many providers default to 3600 (one hour), 14400 (four hours) or even 86400 (one day). If your A record has a TTL of 86400 when you switch, some visitors can keep reaching the old server for a full day.
At your current DNS provider, change the TTL on the records you will be changing (usually the @ and www A or CNAME records) to 300 seconds. Then wait at least as long as the old TTL before switching, because caches holding the old value will not see the new TTL until their copy expires. Doing this 24 to 48 hours ahead is the safe choice.
You can check what the world currently sees with dig (or nslookup on Windows):
dig +noall +answer example.com A
dig +noall +answer www.example.com
nslookup -type=A example.com 1.1.1.1The number after the hostname in the dig output is the remaining TTL. Once it shows 300 or less, you are ready.
One catch: if you are also moving your nameservers (for example from the old host's nameservers to new ones), the NS records are cached at the registry level, often for 24 to 48 hours, and you cannot shorten that. For the smoothest move, keep DNS where it is during the migration and only change the A records. You can move the nameservers later, once the new host is serving the site.
Step 2: Copy your files
Most sites are a folder of files (usually public_html) plus a database. If your old host gives you a control panel, the simplest route is a full backup download. If you have SSH on both sides, copying directly between servers is faster and keeps permissions intact:
# On the old server: pack the site
cd ~
tar -czf site.tar.gz public_html
# Copy it straight to the new server
scp site.tar.gz user@new-server:~/
# Or sync the folder (safe to re-run, only sends changes)
rsync -avz --progress public_html/ user@new-server:~/public_html/With only FTP access, use an FTP client to download everything, then upload it to the new host. Remember hidden files: .htaccess controls rewrites and redirects, and forgetting it is a classic cause of 404 errors on every page except the home page.
Step 3: Export and import the database
Export the database from the old host using phpMyAdmin (Export, Quick, SQL format) or the command line:
# Old server
mysqldump -u olduser -p --single-transaction --default-character-set=utf8mb4 olddb > site.sql
# New server, after creating an empty database and user in the control panel
mysql -u newuser -p newdb < site.sql--single-transaction takes a consistent snapshot of InnoDB tables without locking the site, and setting the character set avoids broken accents and emoji. Large imports may time out in phpMyAdmin, so the command line or your control panel's import tool is more reliable for anything over a few hundred megabytes.
Freeze content during the move
If your site takes orders, comments or form submissions, anything written to the old database after your export will be missing on the new host. For a shop, pick a quiet hour, put the old site into maintenance mode or pause checkout, take the final export and switch DNS shortly afterwards. For a brochure site or blog you can usually just avoid publishing anything until the move is done.
Step 4: Update the configuration
The new host almost certainly uses a different database name, user and password, and possibly a different home directory path. Find your site's config file and update it. Common locations:
| Software | Config file | What to change |
|---|---|---|
| WordPress | wp-config.php | DB_NAME, DB_USER, DB_PASSWORD, DB_HOST |
| Joomla | configuration.php | $db, $user, $password, $host, $log_path, $tmp_path |
| Laravel | .env | DB_DATABASE, DB_USERNAME, DB_PASSWORD, APP_URL |
| PrestaShop 1.7+ | app/config/parameters.php | database_name, database_user, database_password |
WordPress specifics
In wp-config.php, update the database settings. DB_HOST is usually localhost on shared hosting:
define( 'DB_NAME', 'newdb' );
define( 'DB_USER', 'newuser' );
define( 'DB_PASSWORD', 'a-strong-password' );
define( 'DB_HOST', 'localhost' );If the domain stays the same, that is often all WordPress needs. If the domain or the protocol changes (for example moving from a temporary URL, or from http:// to https://), you need a search-replace across the database. Do not do this with a text editor on the SQL file: WordPress stores some settings as PHP serialized data, which records string lengths, and a plain find-and-replace corrupts it. Use WP-CLI, which handles serialized data correctly:
# Preview first
wp search-replace 'http://old-domain.com' 'https://new-domain.com' --all-tables --dry-run
# Then run it for real
wp search-replace 'http://old-domain.com' 'https://new-domain.com' --all-tables
wp cache flushWithout SSH, a plugin such as Better Search Replace does the same job. Afterwards, go to Settings, Permalinks and click Save once to regenerate rewrite rules. Clear any caching plugin as well, since cached pages may still contain old paths.
Step 5: Test on the new server with your hosts file
This step is what makes a zero-downtime move possible. Your computer's hosts file overrides DNS for your machine only, so you can browse your real domain on the new server while everyone else still reaches the old one.
Get the new server's IP address from your hosting welcome email or control panel, then add a line like this:
# Windows: C:\Windows\System32\drivers\etc\hosts (run Notepad as administrator)
# macOS / Linux: /etc/hosts (sudo nano /etc/hosts)
203.0.113.25 example.com www.example.comFlush your DNS cache (ipconfig /flushdns on Windows, sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder on macOS) and restart the browser. Now click through the site properly:
- Home page, several inner pages, and a 404 page.
- Logging in to the admin area.
- Contact forms (check the message actually arrives).
- Search, image uploads, and for shops a test checkout in sandbox mode.
- Any scheduled tasks (cron jobs) the old host ran, which need to be recreated on the new one.
To be sure you are on the new server, temporarily place a file like migration-test.txt on the new host only and open it in the browser. When you are finished testing, remove the hosts file line, or you will keep seeing the new server and miss any DNS problems after the switch.
Step 6: Sort out SSL before the switch
Visitors should never see a certificate warning. The challenge is that free certificates from Let's Encrypt usually validate by checking a file on your domain over HTTP, which only works once the domain points at the new server. There are three ways to handle this:
- Switch, then issue straight away. With a 300 second TTL, most traffic arrives within minutes, and automatic issuing typically completes quickly. A short window on HTTP is the realistic worst case.
- DNS validation. If your control panel supports DNS-based validation, the certificate can be issued before the switch.
- Copy the existing certificate. If you bought a certificate, install the same certificate and private key on the new host so it works the moment traffic arrives.
Once the certificate is active, check that HTTP redirects to HTTPS and there are no mixed content warnings in the browser console.
Step 7: Plan for email (the most common gotcha)
Website and email often share a domain but do not have to share a server. Before you touch DNS, find out where your email currently lives by checking the MX records:
dig +short example.com MXThen decide:
- Email is with a separate provider (such as Google Workspace or Microsoft 365). Leave the MX, SPF, DKIM and DMARC records exactly as they are. Only change the A records for the website. The classic mistake is switching nameservers to a new host whose default zone does not include your MX records, which silently stops all incoming email.
- Email is on the old web host and you want to move it. Create every mailbox on the new host first, with the same addresses. After switching the MX record, connect your mail client to both servers and move old messages across (IMAP clients can drag folders between accounts), or use an IMAP sync tool.
Watch out for an MX record that points at mail.example.com, where that hostname is an A record for the old server. Changing the website's A record does not move it, so update mail as well if email is moving, or leave it alone if it is not. Also update your SPF record if the new server will send mail (contact forms, WordPress notifications, order confirmations), otherwise those messages may land in spam. Keep the old mailboxes open for a week after the switch, since some senders will still deliver to the old server while caches expire.
Step 8: Switch DNS
Update the A record for @ and www (or the CNAME for www) to the new server's IP. If you have an AAAA (IPv6) record pointing at the old host, update or remove it too, because visitors with IPv6 will otherwise keep reaching the old server. Then watch the change spread:
dig +short example.com A @1.1.1.1
dig +short example.com A @8.8.8.8Online tools that query DNS from many countries are useful for confirming the change has spread everywhere. Check the new server's access logs, too: once traffic is arriving there and dropping off on the old host, the move is working.
Step 9: Keep the old host running
Do not cancel the old account the day you switch. Some resolvers ignore low TTLs, some visitors have long-running browser sessions, and you may discover a missing file or forgotten cron job. Keep the old host live for at least three to seven days, ideally until the end of the billing period. During that time, avoid making changes on the old site, and if anything is written there (a late order or form submission), copy it across by hand.
When the old server's logs show no real visitors and email has stopped arriving there, take a final backup for your records, then cancel. Raise the TTL back to 3600 or higher once everything is stable.
Quick checklist
| Before | During | After |
|---|---|---|
| TTL lowered to 300 | Final database export | Hosts file line removed |
| MX records noted | Config and URLs updated | SSL active, HTTPS redirect works |
| Mailboxes created on new host | Tested via hosts file | Forms and email tested live |
| Cron jobs listed | A and AAAA records switched | Old host kept for a few days |
Moving to Zettako
Zettako website hosting includes free Let's Encrypt SSL that is issued and renewed automatically, daily backups, Imunify360 security, Roundcube webmail and one-click installs for WordPress and 400+ other apps through Softaculous. Accounts are set up instantly, so you can create your account, copy your site across and test it with your hosts file before changing a single DNS record. If you would rather not do it alone, we welcome migrations from other hosts and our team will guide you through the transfer.