Tutorials

How to Migrate Your WordPress Site to a New Host Without Downtime

Muhammad SaadMay 10, 20267 min read
How to Migrate Your WordPress Site to a New Host Without Downtime

Whether your current host is too slow, too expensive, or simply unreliable, knowing how to migrate your WordPress site properly is an essential skill. A botched migration can mean hours of downtime, broken links, and lost data. Done right, your visitors won't even notice the switch happened.

This guide walks you through migrating WordPress from one host to another with zero downtime — step by step, with the exact commands and checks you need.

Why Sites Need Migration

Common reasons to migrate your WordPress site include:

  • Performance issues — shared hosting throttling your site during traffic spikes
  • Cost optimization — finding better value with a VPS that gives dedicated resources
  • Better support — switching to a host with responsive technical support
  • Scaling needs — outgrowing your current plan with no upgrade path
  • Security concerns — moving to a host with better infrastructure security

Whatever your reason, the migration process follows the same steps.

Before You Start: Pre-Migration Checklist

1. Document Your Current Setup

Before touching anything, record your current configuration:

# Check PHP version
php -v

# Check MySQL version
mysql --version

# Note your WordPress version
wp core version --path=/var/www/html

# List active plugins
wp plugin list --status=active --path=/var/www/html

Your new host should match or exceed these versions. PHP version mismatches are the #1 cause of post-migration errors.

2. Choose Your New Hosting

For most WordPress sites outgrowing shared hosting, a VPS is the natural next step. A $20-30/month VPS gives you dedicated CPU and RAM that shared hosting can't guarantee. If you're unsure about server management, our guide on managed vs unmanaged VPS hosting can help you decide.

3. Set Up the New Server

On your new VPS, install the LEMP stack:

sudo apt update && sudo apt upgrade -y
sudo apt install nginx mysql-server php8.3-fpm \
  php8.3-mysql php8.3-xml php8.3-mbstring php8.3-curl \
  php8.3-zip php8.3-gd php8.3-redis -y

Create a database for WordPress:

sudo mysql -e "CREATE DATABASE wordpress_db;"
sudo mysql -e "CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'strong_password';"
sudo mysql -e "GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wp_user'@'localhost';"
sudo mysql -e "FLUSH PRIVILEGES;"

How to Migrate Your WordPress Site: Step by Step

Step 1: Back Up Everything

Never migrate without a complete backup of your current site:

# Export the database
mysqldump -u wp_user -p wordpress_db > backup.sql

# Archive all WordPress files
tar -czf wordpress_files.tar.gz -C /var/www/html .

Download both files to your local machine as a safety net.

Step 2: Transfer Files to the New Server

Use rsync for efficient file transfer — it only copies what's needed and preserves permissions:

# From your local machine or old server
rsync -avz --progress /var/www/html/ user@new-server:/var/www/wordpress/

Or if you backed up as an archive:

scp wordpress_files.tar.gz user@new-server:/var/www/
ssh user@new-server "cd /var/www && tar -xzf wordpress_files.tar.gz -C wordpress/"

Step 3: Import the Database

Transfer and import your database dump:

# Copy database dump to new server
scp backup.sql user@new-server:/tmp/

# Import on the new server
ssh user@new-server
mysql -u wp_user -p wordpress_db < /tmp/backup.sql

Step 4: Update wp-config.php

Edit the WordPress configuration on the new server to match your new database credentials:

define('DB_NAME', 'wordpress_db');
define('DB_USER', 'wp_user');
define('DB_PASSWORD', 'strong_password');
define('DB_HOST', 'localhost');

If your domain stays the same (which it should for zero-downtime migration), you don't need to change WP_HOME or WP_SITEURL yet.

Step 5: Configure Nginx

Create your Nginx server block:

server {
    listen 80;
    server_name yourdomain.com www.yourdomain.com;
    root /var/www/wordpress;
    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}

Enable and test:

sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

Step 6: Set Correct Permissions

sudo chown -R www-data:www-data /var/www/wordpress
sudo find /var/www/wordpress -type d -exec chmod 755 {} \;
sudo find /var/www/wordpress -type f -exec chmod 644 {} \;

Step 7: Test Before Switching DNS

This is the critical zero-downtime step. Test your site on the new server before changing DNS:

# Add a temporary hosts file entry on your local machine
# On Mac/Linux: /etc/hosts
# On Windows: C:\Windows\System32\drivers\etc\hosts

NEW_SERVER_IP yourdomain.com www.yourdomain.com

Open your browser and visit your domain. It will load from the new server while everyone else still sees the old one. Check:

  • Homepage loads correctly
  • All pages work
  • Admin dashboard accessible
  • Forms submit properly
  • Images display correctly
  • Plugins function normally

Step 8: Switch DNS

Once everything checks out, update your DNS records:

A    @    → NEW_SERVER_IP
A    www  → NEW_SERVER_IP

Pro tip: Lower your DNS TTL to 300 seconds (5 minutes) at least 24 hours before migration. This ensures the DNS change propagates quickly.

Step 9: Install SSL

After DNS propagates to the new server:

sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com

Step 10: Final Verification

Remove the hosts file entry you added in Step 7 and verify your site loads correctly through normal DNS. Check SSL is working (padlock icon in browser).

Post-Migration Optimization

Now that your site is on a better host, optimize it. If you've followed our staging environment guide, set up a staging copy on your new server for future updates.

Essential post-migration steps:

# Install Redis for object caching
sudo apt install redis-server php8.3-redis -y

# Enable OPcache for faster PHP
sudo phpenmod opcache
sudo systemctl restart php8.3-fpm

Install a caching plugin (WP Rocket or W3 Total Cache) and run a speed test to confirm your new host delivers better performance.

Common Migration Problems and Fixes

White screen after migration: Usually a PHP version mismatch. Check wp-content/debug.log for specific errors. Ensure all required PHP extensions are installed.

Broken images or links: If you changed domains, run a search-replace on the database:

wp search-replace 'old-domain.com' 'new-domain.com' --path=/var/www/wordpress

Database connection errors: Double-check wp-config.php credentials match exactly what you created in MySQL. Test the connection manually:

mysql -u wp_user -p wordpress_db -e "SELECT 1;"

Permalink errors (404 on all pages except homepage): Nginx needs the try_files directive. Make sure your server block includes the location / block shown in Step 5.

Email not sending: If your old host handled email, you may need to configure SMTP. Install an SMTP plugin and use a service like SendGrid or your email provider's SMTP settings.

FAQ

How long does a WordPress migration take?

A typical migration takes 1-3 hours for the actual work, plus up to 48 hours for DNS propagation. With the hosts file testing method, your site has zero downtime during the switch.

Can I migrate my WordPress site without SSH access?

Yes, but it's slower. Use plugins like All-in-One WP Migration or Duplicator to export and import. These work through the WordPress admin panel and don't require command-line access.

Should I cancel my old hosting immediately after migration?

No. Keep your old hosting active for at least 72 hours after switching DNS. This ensures you have a fallback if anything goes wrong and covers the full DNS propagation window.

Will my SEO rankings be affected by migration?

If you keep the same domain and URLs, your rankings should not be affected. Google may notice a brief change in server response times, but this typically resolves within days. Faster hosting often improves rankings.

Migrate to Better Hosting with DeployBase

Ready to migrate your WordPress site to hosting that actually performs? At DeployBase, we offer VPS plans starting at $5/month with NVMe SSD storage, full root access, and 24/7 support. Our team can assist with your migration — ensuring zero downtime and optimal configuration from day one.

Start your migration to DeployBase → — faster hosting, full control, no compromises.

Share this article

Muhammad Saad

Muhammad Saad

DeployBase Team

Ready to Get Started?

Join thousands of developers who trust DeployBase for their hosting needs.