Moving a site is one of those jobs that feels risky until you have done it once. The good news is that the process is the same every time, and most of the risk comes from skipping the basics. This guide shows you how to migrate WordPress to a new host, or to a new domain, with a backup at the start, a test before the switch and a checklist at the end.
The short version
- Back up before you do anything. Files and database, with a copy somewhere off the server.
- Copy, then test, then switch. Get the new site working on the new host before you change DNS.
- Moving host is easy. Changing domain needs extra steps. URLs inside the database must be updated, and old addresses redirected.
- Do not forget email. If your email uses the same domain, check your DNS records before you switch.
Moving host or moving domain: know which one you are doing
Two different jobs share the word “migration”, and they need different amounts of work. Decide which one you are doing before you start.
| Aspect | New host, same domain | New domain |
|---|---|---|
| What moves | Files and database | Files, database and every address inside them |
| URLs in the database | Usually stay the same | Must be updated |
| Redirects needed | None | 301 redirects from the old domain to the new one |
| SEO risk | Low if the switch is clean | Higher, so plan it carefully |
| Switch step | Point DNS to the new host | Update addresses, then redirect the old domain |
The steps below cover both. Where a step only applies to a domain change, it says so. For background reading, the official guide to moving WordPress covers the same ground in more depth.
Before you begin: preparation
A calm migration depends on what you do before it starts.
- Choose and set up the new host first. Make sure the new plan has enough space and a PHP and database version that your site supports.
- Take a full backup of the files and the database and download a copy. Our WordPress backup guide links to the official instructions.
- Pause changes to the old site. New orders, comments or posts made during the move can be lost. Choose a quiet time and tell your team.
- Lower your DNS time-to-live (TTL) a day or two before the switch, if your DNS provider lets you. A lower TTL means the new address spreads sooner.
- Write down your DNS records, especially mail records, before you change anything.
Do not cancel the old hosting until you have checked the new site thoroughly and DNS has settled. If something goes wrong, the old site is your way back.
Three ways to move the site
There is more than one way to migrate WordPress to a new host. The method decides how much of the work you do yourself, so choose it before you start.
| Method | How it works | Best when |
|---|---|---|
| Your new host moves it | The host copies your site, often for free on some plans | You want the least work and the host has a clear process |
| A migration plugin | The plugin packs the site and unpacks it on the new host | The site is small or medium and you want a guided route |
| By hand | You copy the files and database yourself and edit the settings | The site is large, unusual or you want full control |
Whichever you choose, keep your own backup. The manual route below is the one every other method is built on, so it is worth understanding even if you let someone else do the work.
Step by step: how to migrate WordPress to a new host
- Export the database. Use phpMyAdmin, or run
wp db exportover the command line. Keep the .sql file safe. - Download the files. Copy the whole WordPress folder, including
wp-content(your themes, plugins and uploads) andwp-config.php. - Create a new database and user on the new host. Note the database name, user, password and host name.
- Import the database into the new database, using phpMyAdmin or the command line.
- Upload the files to the new host, into the folder that will serve your site.
- Edit
wp-config.phpso it uses the new database name, user, password and host. - Check the file permissions. The WordPress guide notes that files showing
0000permissions should be changed to0644. - Test the site before changing DNS (see the next section).
- Switch DNS so your domain points to the new host.
- Run the final checks at the end of this guide.
If you are changing the domain as well
Two extra jobs apply. First, update the site address: in Settings, General, set the WordPress Address and the Site Address to the new domain, including https:// and with no trailing slash. Second, replace the old address inside your content with a tool that understands serialised data, not a plain text find-and-replace.
The WordPress guide warns that a careless replace can break serialised data when the length of the address changes, and that you should never change the guid column. WP-CLI’s search-replace command handles both, and --dry-run shows you what would change first.
Test the new site before you switch DNS
This is the step that separates a smooth migration from a stressful one. You can view the new site on its new server while the public still sees the old one.
- Find the new server’s IP address in your new host’s control panel or welcome email.
- Edit the hosts file on your own computer so your domain points to that IP. This affects only your computer.
- Open your site in a private window. You are now seeing the new host, even though the world still sees the old one.
- Click through the important pages. Log in to the dashboard, open a post, submit the contact form and, for a shop, place a test order.
- Remove the hosts file entry when you have finished testing.
If your host offers a temporary address for the new site, you can use that instead of the hosts file.
Switching DNS without losing email
DNS is the phone book that tells browsers where your site lives. Changing it points visitors at the new host. It can also break email if you are not careful, because the same DNS records control where mail goes.
| Record | What it controls | What to do |
|---|---|---|
| A record (and AAAA) | Where your domain points | Change it to the new host’s IP address |
| CNAME | Aliases such as www | Make sure www points to the right place |
| MX | Where your email is delivered | Do not change it unless you are also moving email |
| TXT (SPF, DKIM, DMARC) | Email authentication and verification | Keep them as they are, unless your mail provider tells you to change them |
| Nameservers | Which provider controls all of the above | If you change them, copy every record to the new provider first |
You can either change the A record at your current DNS provider, or move the nameservers to the new host. Changing only the A record is the safer choice if you use email on the domain, because the other records stay exactly where they are.
DNS changes can take a few hours to spread, and sometimes longer. That is why the old site stays up. When visitors reach the new host, you will see traffic move over.
If your site is a shop or takes bookings
Orders and bookings made on the old site while you move are the easiest thing to lose. Pick a quiet time, put the shop in maintenance mode or pause checkout while you copy the database, and check afterwards that no order was placed in the gap. After the switch, place a test order and confirm that the emails and the payment gateway work on the new host.
Permalinks, redirects and .htaccess
Pretty URLs depend on rewrite rules. After the move, go to Settings, Permalinks and save without changing anything, which rebuilds the rules. If you had custom redirects or other rules in your old .htaccess, copy them across and check that they point to the right addresses.
If you changed the domain, add permanent (301) redirects from every old address to its new equivalent, so that visitors, links and search engines land on the right page. Google’s guide to moving a site with URL changes explains what to do in Search Console as well.
The final checklist
After the switch, spend half an hour checking the site as a visitor would.
- The home page and a few inner pages load over https, with no browser warnings.
- Images, fonts and downloads appear. Missing images usually mean old addresses.
- Forms send email and you receive it. Test every form.
- Login and password reset work.
- Shop and payments work. Place a test order and check the emails.
- The sitemap and robots.txt are right and search engines are allowed in.
- Search Console and analytics still collect data. If the domain changed, use the change-of-address tool and update your property.
- Scheduled tasks run. Check backups, scheduled posts and any cron jobs.
- A fresh backup of the new site exists.
Common problems and quick fixes
| What you see | Likely cause | What to try |
|---|---|---|
| “Error establishing a database connection” | Wrong details in wp-config.php | Check the database name, user, password and host |
| The site redirects to the old address | The old URL is still set in the options or in the content | Check siteurl and home, then run a search and replace |
| Images are broken | Old addresses, or the uploads folder is missing | Replace the old URLs and check the uploads folder |
| Pages return 404 errors | Rewrite rules missing | Save the permalinks again and check .htaccess |
| Mixed content warnings | Some links still use http | Replace http addresses with https |
| Email stopped working | MX records changed by mistake | Restore the original MX and TXT records |
A plugin can do much of this work for you, and so can your new host. If you would rather make a copy first, read our guide on how to clone a WordPress site, which uses the same steps. And if you are starting from scratch, how to create a website covers the setup.
Frequently asked questions
Will migrating hurt my search rankings?
A clean move to a new host with the same domain and the same addresses should not. A change of domain carries more risk, so redirect every old page to its new address and tell Search Console. Nobody can promise that rankings will not move.
How long does a WordPress migration take?
For a typical small site, an hour or two of hands-on work. DNS can take longer to spread, so keep the old site running until you are sure.
Will my site go down during the move?
It does not need to. The site stays live on the old host while you build the copy, and visitors move across when DNS changes.
Can my new host move the site for me?
Many hosts offer a migration service or a plugin. Ask what is included, whether it covers email, and still keep your own backup.
Should I use a plugin or move it by hand?
Plugins are quicker for small and medium sites. A manual move gives you more control, which helps with large or unusual sites. Both follow the same steps.
What if something goes wrong?
Switch DNS back to the old host, which should still be running. Then use your backup and the troubleshooting table to find the cause before trying again.
