Switching WordPress host with minimal downtime for visitors
Switching host isn’t just about copying files: the WordPress database holds serialised data that wraps URLs, and a careless replace corrupts it silently. Here’s the method I follow, from the first export through to the final DNS switch.
What URL replacement touches at a deep level
WordPress stores some of its settings (theme options, widget configuration, plugin preferences) as serialised PHP data in text columns of the MySQL database. A serialised string encodes the exact length of every substring it contains: for example, s:22:"https://old-site.co.uk" means “a 22-character string, here’s its content”. If the test or destination site uses a different URL (a temporary address, subdomain, or IP), and it’s replaced with a plain SQL UPDATE using REPLACE(), the number declared before the quotes no longer matches the new string length.
It’s not a marginal case: on a WooCommerce shop, the old site’s address can turn up in dozens of separate serialised records (payment gateway settings, cart widgets, shipping extension preferences), each one potentially corrupted by a blunt replace. It’s this scattered volume that makes the problem hard to spot at a glance before a customer reports a specific glitch.
WordPress then fails to deserialise the data correctly: theme settings reset to defaults, widgets disappearing from the sidebar, empty plugin options, often with no visible error for days. The correct method goes through a tool that recalculates these lengths on every replacement, typically the WP-CLI command wp search-replace old-url new-url --all-tables.
How I switch host without visible downtime
-
Copying files and database
I copy the entire site’s files and a full database export to the new hosting, without touching the live site.
-
Adapting wp-config.php
I fill in the new database connection details (name, user, password, host) in wp-config.php on the new environment.
-
Fixing URLs with wp search-replace
If the test site is reachable under a different address (temporary subdomain, IP), I fix the stored URLs with wp search-replace, which recalculates serialised string lengths instead of breaking them.
-
Validating via the local hosts file
I test the site on the new hosting by temporarily editing my machine’s hosts file, which points to the new server without touching the public DNS or affecting visitors.
-
Lowering the DNS TTL beforehand
A few days before the switch, I lower the TTL (time to live) of the DNS records to speed up propagation once the change happens.
-
Switching DNS or server during low traffic
I schedule the switch for a low-traffic window, and carry over any orders or messages received between the initial copy and the final switch if the site sells online.
Going further
-
Changing domain name without losing your rankings
The same serialisation mechanism applies, plus managing 301 redirects to the new domain.
-
Moving a WordPress site to HTTPS
A URL change of the same nature, this time on the protocol, following the same correction logic.
-
Choosing hosting for e-commerce
The criteria I check before recommending a host for a WooCommerce shop.
-
Understanding PHP serialisation
The full definition of the mechanism covered on this page.
Describe your need in one minute
A few targeted questions so I can reply with an estimate rather than another questionnaire.