Migrating WordPress to a new server and domain by hand — backup, database move, serialized-data-safe URL replacement, Cloudflare fixes, and the post-move SEO checklist. For self-hosters on VPS or cloud instances behind Cloudflare who want full control without losing data, settings, or rankings.
My previous WordPress setup lived on a cloud instance that required a port number in the URL — a hassle for visitors and terrible for SEO. So I moved it to a new instance and a clean domain, by hand, and documented every step.
You can do this with a plugin — Route B covers when that makes sense — but the manual route gives you full control and shows you where a WordPress site can break during a move. One warning: an earlier version of this guide recommended fixing URLs with raw SQL in phpMyAdmin. That was wrong; the corrected method is below.
Before You Start: Checklist and Rollback Plan
Do not start by shutting anything down: a calm migration keeps the old site running until the new one is proven.
- Back up twice: a full archive of the web root plus a database export, one copy off the server. Open the archive and skim the SQL — an unexamined backup is a hope, not a backup.
- Keep the old site alive for one to two weeks after the switch — if anything goes wrong, rollback is just pointing DNS back.
- Lower the DNS TTL for both domains (300 seconds works) at least a day ahead, so the final switch propagates in minutes instead of hours.
- Make a quick inventory: site size, plugin list, and anything pointing at the old domain — cron jobs, webhooks, uptime monitors, hotlinked images.
For a practice run, a local container setup is a safe rehearsal box — on Windows, our guide to running Linux containers in WSL without Docker Desktop works well.
Route A: Manual Migration, Step by Step
This is the route I used: no plugins, just files, a database, and wp-config.php.
1. Back Up Files and Database
Archive the entire web root on the old server and download it. Export the database from phpMyAdmin, or with mysqldump over SSH. Sanity-check the export: it should contain your wp_posts data and end cleanly, not stop mid-table.

2. Create the New Database and Import
Create a fresh database and user on the new server and import the SQL file, then update wp-config.php:
/** Database name */
define('DB_NAME', 'your_db_name');
/** Database username */
define('DB_USER', 'your_db_user');
/** Database password */
define('DB_PASSWORD', 'your_db_password');
One field people miss is DB_HOST: ‘localhost’ suits most setups, but some hosts expect a socket path or separate hostname. If you get “Error establishing a database connection”, check DB_HOST first, then the credentials — a single typo keeps the site from connecting.
3. Upload Files and Fix Permissions
Extract the archive into the new web root, set directories to 755 and files to 644, and make sure the web server can write to wp-content/uploads — wrong permissions surface later as failed uploads and broken resizing.
4. Update the Site URL
Log in and go to Settings > General to set the WordPress Address and Site Address. Locked out because the database still points at the old URL? WordPress.org documents two rescue options: temporarily define WP_HOME and WP_SITEURL in wp-config.php, or the RELOCATE method — add define('RELOCATE', true); to wp-config.php and visit wp-login.php once so WordPress updates the stored URLs. Remove the temporary lines afterwards.
5. Flush Permalinks
Go to Settings > Permalinks and click Save Changes without changing anything; this regenerates the rewrite rules. Skipping it is the classic reason migrated sites show the homepage but 404 everywhere else.
Fix Every URL Safely: Search-and-Replace Without Breaking Serialized Data
After the move the site loads, but post content, image URLs, and many settings still name the old domain. This is where migrations quietly go wrong: WordPress stores widgets, theme/plugin settings, and builder data in PHP serialized format, where every string carries a length prefix, like s:15:"old-domain.com". A plain replacement changes the string but not the prefix, so any length difference between old and new domain corrupts that data — usually silently. Settings vanish, widgets disappear, and nothing logs an error.
That is why the old version’s raw REPLACE() queries were dangerous — never run them across post_content or postmeta. One safe exception: home and siteurl in wp_options are plain strings, so updating just those two rows directly is fine.
Option 1: Better Search Replace (Dry Run First)
Install the free Better Search Replace plugin, open Tools > Better Search Replace, select the tables, and tick dry run first — it shows how many rows will change. If the numbers look sane, run it for real; the plugin unserializes, replaces, and re-serializes correctly. (The free version suffices here; I have not tested its Pro add-on.)
Option 2: WP-CLI
With shell access, WP-CLI does the same job:
wp search-replace 'old-domain.com' 'new-domain.com' --dry-run wp search-replace 'old-domain.com' 'new-domain.com' --skip-columns=guid
Review the dry run, then run it for real — the –skip-columns=guid flag is not decoration (see below).
The One Thing You Must Never Replace: GUID
WordPress stores a GUID for every post, and the official documentation is blunt: “Never, ever, change the contents of the GUID column, under any circumstances.” The GUID is how feed readers identify your posts — change it, and subscribers’ readers treat your archive as brand-new content. Whatever tool you use, leave the GUID alone.
Route B: The Plugin Shortcut (All-in-One WP Migration) and Its Real Limits
If you would rather not touch a database, All-in-One WP Migration is the standard shortcut: export the whole site to a single .wpress file, install the plugin on the new host, import. For a small site on a cooperative host, it is faster than Route A. Rebuilding the host anyway? A declarative container setup like the one in our Docker Agent YAML guide turns the next swap into mostly copy-and-redeploy.
About the limits: roundups often claim the free version caps restores at 512 MB. ServMask, the maker, says the free version sets no size limit of its own — the ceiling in the import screen is your host’s PHP upload_max_filesize and post_max_size. If the host lets you raise those, the free version is usually enough. The Unlimited Extension ($69/year for up to 50 sites, per the vendor’s product page; I have not tested the paid version) works around host limits with chunked transfers. Behind Cloudflare, uploads through the proxy hit its 100 MB free-plan cap first, whatever the host allows.
In short: manual for control, domain changes, and large sites; the plugin for speed on quick host swaps.
If Your Site Is Behind Cloudflare
Both my sites run behind Cloudflare, and migration day is when it causes the most confusing failures. Three checks:
- Purge everything. After the switch, run Purge Everything in Cloudflare, then check old Page Rules and Cache Rules for anything pointing at the old domain or origin.
- Get SSL right before you flip DNS. Install a valid certificate on the new origin, then set Cloudflare to Full (Strict). Flexible makes Cloudflare fetch over HTTP; if the origin forces HTTPS, they chase each other into an ERR_TOO_MANY_REDIRECTS loop — treat Flexible as an emergency bridge only.
- Expect Bot Fight Mode to bite. On my other site, it blocked my own tooling with error 1010 until requests carried a normal browser user agent. The free plan cannot skip it with WAF rules, so during the migration window either turn it off briefly or whitelist your IP under IP Access Rules — otherwise migration plugins, REST calls, and webhooks fail with 403s that look like server problems.
After a Domain Change: The SEO Checklist
A domain change is where rankings are lost — the part the old version skipped entirely. Do these in order:
- Redirect every URL. Set up page-to-page 301s from each old URL to its counterpart — not a blanket redirect to the homepage, which Google treats as a soft 404. Keep the redirects and the old domain for at least a year.
- Use Search Console’s Change of Address tool. Both properties must be verified under the same Google account, with the homepage 301 already live; Google then prefers the new domain and forwards signals for 180 days. The tool does not apply to http-to-https moves, www-to-non-www changes, or path-only changes — redirects and sitemaps handle those.
- Submit the new sitemap in the new property. When I resubmitted this site’s sitemap in October 2026, a stale cache kept dead URLs listed until it was flushed — check the sitemap itself is fresh, not just resubmitted. Then watch coverage as old URLs flip to redirect status.
- Point internal links at the final URLs. Redirects are a safety net, not a routing strategy — navigation, in-post links, and image sources should use the new domain directly. That is the search-and-replace job above; do not do it twice.
Finish with a smoke test: homepage, an old post, an image-heavy page, admin login, a comment or form, and the RSS feed. If all six behave, you are done.
Frequently Asked Questions
Can I migrate WordPress to a new domain with a plugin instead of doing it manually?
A: Yes — All-in-One WP Migration is the common choice. Ignore the widely repeated “512 MB free limit”: per ServMask, the free version sets no limit of its own; the real ceiling is your host’s PHP upload settings. Large sites, restrictive hosts, or a domain change — where you also need safe URL replacement and redirects — call for the manual route.
Why did my widgets and settings break after I replaced URLs in phpMyAdmin?
A: Raw SQL REPLACE() does not recalculate the length prefixes in serialized data, so widget, theme, and builder settings are silently corrupted whenever the new domain differs in length from the old. Restore the affected tables from backup and redo the replacement with Better Search Replace or WP-CLI, which handle serialized data properly — dry-run first.
Should I change the GUID values when I change domains?
A: Never. WordPress.org’s documentation says: “Never, ever, change the contents of the GUID column, under any circumstances.” The GUID is the permanent identifier feed readers use; changing it makes every old post look brand new to subscribers. WP-CLI users should always pass –skip-columns=guid.
Will changing my domain hurt my Google rankings?
A: Short-term fluctuation is normal; lasting damage is avoidable. Redirect every old URL to its counterpart with a 301, submit the Change of Address in Search Console (signals forward for 180 days), resubmit your sitemap in the new property, and keep the redirects and old domain for at least a year.