Migrating a Site to a New Host
Move a website between hosts with no lost data and almost no downtime: back up, copy, test privately, then switch your domain.
// Safe move order 1. back up everything 2. copy site to new host 3. test before switching 4. point the domain 5. keep old host 1-2 weeks
🧰 What you need first
- Access to both hosting accounts
- Access to your domain's DNS or nameservers
- A recent full backup
🎯 What you'll learn
- Copy files and the database to a new host
- Test the new copy before visitors see it
- Switch over with almost no downtime
🛠 Tools needed
- Both control panels
- A migration plugin (for WordPress) or SFTP
- Your registrar account
The plan
A website is two things: files and usually a database. Moving hosts means copying both, checking the copy works, then pointing your domain at the new place.
Tip: Many hosts migrate your site for free. Ask your new host before doing it yourself.
Prepare
- Take a full backup of files and database at your old host, and download it
- Write down your email settings and DNS records, especially MX and TXT
- A day ahead, lower your DNS records' TTL to 300 seconds so the switch spreads faster
- Don't cancel your old hosting yet
WordPress: use a migration plugin
Migration plugins pack up your whole site and unpack it on the new host. A few popular ones, in alphabetical order:
- All-in-One WP Migration
- Duplicator
- Migrate Guru
mC0de isn't paid by any of them. Free versions may limit the size of a site you can move.
- Install a fresh WordPress at your new host (most hosts have a one-click installer).
- Install the same migration plugin on both sites.
- Export from the old site and import into the new one.
- Log in to the new site with your old username and password.
Any site: move it by hand
- Download all your site files with SFTP or a Backup tool.
- Export the database with phpMyAdmin (Export → SQL).
- At the new host, create a new database and user.
- Upload the files and import the database.
- Update the site's config file (for WordPress,
wp-config.php) with the new database name, user and password.
Test before switching
Your domain still points at the old host, so you need another way to preview the new copy:
- Use your new host's temporary URL or preview link, if it has one.
- Or edit your computer's hosts file to point your domain at the new server's IP, just for you.
- Pages, images and menus load
- You can log in and save changes
- Forms and checkout work
Switch the domain
Change your nameservers or A records to the new host. Visitors move over gradually as DNS spreads, usually within a few hours.
Warning: If you switch nameservers, recreate your email (MX) records at the new host first, or your email can stop arriving.
Finish up
- Run SSL at the new host once the domain points there
- Avoid edits on the old site during the switch, or they'll be lost
- Keep the old host for 1–2 weeks, then cancel
Common problems
"Error establishing a database connection"
Why: The database details in the config file don't match the new host.
Fix: Check the database name, user, password and host in wp-config.php.
Images and links still go to the old address
Why: Old URLs are stored in the database.
Fix: Use a search-and-replace tool to update them. Back up first.
Email stopped after the move
Why: MX records weren't copied before switching nameservers.
Fix: Add your email provider's MX records at the new DNS host.
Key takeaways
Keep going
- Get the domain switch right: Pointing a Domain at Your Host
- Then turn on SSL at the new host: Installing a Free SSL Certificate
Enjoyed this guide?
Support free learning at mC0de.
