WordPress

How to Move a WordPress Site to Another Host

Migrate WordPress with no downtime. Plugin route or manual, how to test on the new server before changing DNS, and how to avoid losing email or emptying the cart.

A WordPress site being migrated between two servers

Moving a WordPress site sounds risky and mostly is not — provided you do one thing: test the site fully on the new server before you point the domain at it.

That single habit turns a nervous migration into a boring one. Here is the whole process both ways, plus the details that catch people out.

Two days before: lower your DNS TTL

Do this first, because it takes time to take effect.

TTL tells the internet how long to remember your DNS records. The default is often 24 or 48 hours, which means some visitors keep reaching the old server for two days after you switch.

In your DNS panel, change the TTL on the A record to 300 seconds. Wait for the old TTL to expire, then migrate. The switch then propagates in about five minutes instead of two days.

Raise it back to a normal value once everything is settled.

Before you start: what you are moving

A WordPress site is exactly two things:

  1. The files — WordPress core, themes, plugins, uploads
  2. The database — posts, pages, settings, users, comments

Miss either and the site does not work. Everything below is just moving both safely.

Method 1: A migration plugin

The right choice for most sites. Duplicator, All-in-One WP Migration or Migrate Guru all work.

On the old host

  1. Install the plugin and run the export
  2. It builds one archive containing files and database together
  3. Download it, plus the installer file if the plugin provides one

On the new host

  1. Create an empty database, a user, and grant all privileges. Note all three.
  2. Upload the archive and installer to the new server's web root
  3. Open the installer in a browser — using the server IP or a temporary URL, not the domain, which still points elsewhere
  4. Enter the database details and run it

Free tiers have size limits. All-in-One WP Migration caps free imports at a few hundred megabytes. A media-heavy site will exceed it, and then the manual method below is faster than paying.

Method 2: Manual migration

More steps, no size limits, and nothing hidden from you.

1. Export the database

cPanel → phpMyAdmin → select the database → Export → Quick → SQL → Go.

For a large database use Custom and tick Add DROP TABLE, which makes re-importing cleaner if you have to retry.

2. Download the files

The fastest route is to zip on the server first: File Manager → select all in public_html → Compress → download the zip. Downloading thousands of small files over FTP takes hours; one zip takes minutes.

3. Upload to the new host

Upload the zip into public_html on the new server and extract it there.

4. Import the database

Create the database and user on the new host, then phpMyAdmin → select it → Import → choose your SQL file → Go.

If the file is too large to upload, use the SSH route:

mysql -u newuser -p newdatabase < backup.sql

5. Update wp-config.php

define( 'DB_NAME', 'new_database' );
define( 'DB_USER', 'new_user' );
define( 'DB_PASSWORD', 'new_password' );
define( 'DB_HOST', 'localhost' );

Some hosts use something other than localhost — check their documentation.

Test before you switch the domain

This is the part that makes migration safe, and almost nobody does it.

Edit the hosts file on your own computer so that your machine resolves the domain to the new server, while the rest of the world still reaches the old one.

Windows: C:\Windows\System32\drivers\etc\hosts (open Notepad as administrator)
Mac and Linux: /etc/hosts

Add one line:

203.0.113.45    yourdomain.com
203.0.113.45    www.yourdomain.com

Use the new server's IP. Save, then open your domain in a browser — you are now seeing the new server while everyone else sees the old one.

Check all of this

  • The homepage and several inner pages
  • Images actually load
  • Log in to wp-admin
  • Submit the contact form and confirm the email arrives
  • Search
  • If it is a shop: add to cart, reach checkout
  • Open it on a phone

Found a problem? Fix it with zero pressure — the live site is untouched. When everything works, remove the hosts lines.

Switch the domain

Change the nameservers at your registrar to the new host's, or update the A record to the new IP.

With TTL already lowered, most visitors move within minutes.

Keep the old hosting running for at least a week. It costs a few dollars and gives you somewhere to go back to. Cancelling immediately is the one mistake with no recovery.

After the switch

  1. Install SSL on the new host. The old certificate does not travel. See the WordPress SSL guide.
  2. Re-save permalinks — Settings → Permalinks → Save. This rewrites .htaccess on the new server.
  3. Clear every cache — plugin, host and Cloudflare.
  4. Check Search Console for a spike in crawl errors over the next few days.
  5. Test email again from the live domain, not just the hosts-file version.

Email — the thing people forget

If your email is on the same host as the website, moving nameservers moves your email too. Messages start arriving at a new, empty mailbox on a server you have not configured.

Before switching, decide:

  • Email staying where it is? Copy the existing MX records to the new DNS before the change. Check them twice.
  • Email moving too? Create the mailboxes on the new host first, and download anything important from the old ones.
  • Using Google Workspace or similar? Copy those MX records across exactly.

Lost email is worse than a broken website, because you cannot tell what you missed.

Common problems

"Error establishing a database connection"

Wrong credentials in wp-config.php, or the user was not granted privileges on the database. Test directly:

mysql -u newuser -p newdatabase

The homepage works but every other page is 404

.htaccess did not transfer, or AllowOverride All is missing on the new server. Re-save permalinks first; if that fails, it is the Apache config.

The site loads but has no styling

Old URLs in the database, usually if the domain or protocol changed. Run a search and replace with Better Search Replace or WP-CLI.

Images are missing

The uploads folder did not transfer completely, or permissions are wrong. Check wp-content/uploads exists and is owned by the web server user.

Some visitors see the old site

Normal during propagation. It resolves as caches expire — faster if you lowered the TTL in advance.

The site is slower than before

Caching plugins store server-specific paths. Deactivate, reactivate and reconfigure the caching plugin on the new host.

A safe order of work

  1. Two days before: lower DNS TTL to 300
  2. Sort out the email plan
  3. Back up files and database, and keep a copy off both servers
  4. Move everything to the new host
  5. Test with the hosts file until it is genuinely finished
  6. Switch DNS
  7. Install SSL, re-save permalinks, clear caches
  8. Watch for a week, then cancel the old host

Where to go next

Questions people ask

How do I move a WordPress site without any downtime?
Copy everything to the new host first, then edit the hosts file on your own computer so only you resolve the domain to the new server. Test the whole site there while the world still sees the old one, and only change DNS once it works.
How long does DNS propagation take?
Normally a few hours, but up to 48 if your TTL is high. Lower the TTL on the A record to 300 seconds two days before you migrate, and the switch then propagates in about five minutes.
Will moving hosts affect my Google ranking?
Not if the URLs stay the same and the site does not go down. Keep the same domain and structure, re-save permalinks after the move, and watch Search Console for crawl errors in the following days.
What happens to my email when I move hosting?
If email is on the same host, changing nameservers moves it too and messages start arriving at a new empty mailbox. Decide first: either copy the existing MX records to the new DNS, or create the mailboxes on the new host before switching.
Should I use a migration plugin or do it manually?
A plugin for most sites — Duplicator or All-in-One WP Migration are reliable. Go manual if the site is large, because free plugin tiers cap import size and the manual route has no limit.
Why does my migrated site show a database connection error?
The credentials in wp-config.php do not match the new database, or the user was not granted privileges on it. Test the login directly with mysql -u newuser -p newdatabase before blaming WordPress.
Why is only my homepage working after the move?
The .htaccess file did not transfer, or the new server is missing AllowOverride All. Re-save Settings then Permalinks first — that rewrites the file. If it persists, it is the Apache configuration.
My site has no styling after migrating. What is wrong?
Old URLs are still stored in the database, which happens when the domain or the protocol changed. Run a search and replace with Better Search Replace or WP-CLI, then clear all caches.
How long should I keep the old hosting?
At least a week after the switch. It costs very little and gives you somewhere to go back to if something surfaces later. Cancelling immediately is the one migration mistake with no recovery.
Do I need to reinstall SSL on the new host?
Yes. Certificates are tied to the server and do not travel with the files. Install a free Let's Encrypt certificate on the new host, ideally right after the DNS change resolves.

Written by Habib Baloch

I build Android apps, websites and Ubuntu servers, and write down exactly how I did it.

Ask me about this guide →