How to Fix a Failed WordPress Migration to a New Server
Moving a WordPress site to a new server can fail for many reasons, from database connection errors to missing files. This guide walks you through the most common failure points and gives you clear, step-by-step fixes to get your site back online quickly.
What You’ll Need
- FTP/SFTP access to both the old and new servers (or a file manager in your hosting panel)
- phpMyAdmin or another database management tool on both servers
- The new server’s database credentials (host, database name, username, password)
- A text editor (like Notepad++ or VS Code) to edit configuration files
- A backup of your WordPress files and database (if you don’t have one, create one before proceeding)
Step-by-Step
- Identify the exact error. The first step is to know what kind of failure you’re facing. Common errors include:
- “Error establishing a database connection” – database credentials or host are wrong.
- “404 Not Found” on all pages except the home page – permalinks need to be flushed.
- White screen of death (blank page) – PHP error or memory limit issue.
- Mixed content warnings (http/https) – the site URL is still pointing to the old domain.
- Check your wp-config.php file. Open the wp-config.php file in the root of your WordPress directory on the new server. Verify the database name, username, password, and host. The host is often “localhost” but can be a different hostname (like “mysql.example.com”) provided by your new host. If you’re unsure, contact your new hosting provider.
- Test the database connection manually. If the credentials look correct but you still get a database error, try connecting to the database using a tool like phpMyAdmin or a simple PHP script. Create a temporary file named test.php in your WordPress root with the following code:
<?php $conn = new mysqli('DB_HOST', 'DB_USER', 'DB_PASSWORD', 'DB_NAME'); if ($conn->connect_error) { die('Connection failed: ' . $conn->connect_error); } echo 'Connected successfully'; ?>Replace the placeholders with your actual credentials. If this fails, the issue is with your database server or credentials, not WordPress.
- Fix the site URL in the database. If your site loads but with broken links or images, the URLs in the database still point to the old domain. Use phpMyAdmin to open your database and run the following SQL query, replacing
example.comwith your new domain (or old domain if you’re keeping it but moving servers):UPDATE wp_options SET option_value = replace(option_value, 'http://old-domain.com', 'http://new-domain.com') WHERE option_name IN ('siteurl', 'home');Also update the guid column (though not strictly necessary for most cases) and any serialized data (like widget settings) with a more thorough search-replace tool. For serialized data, use a plugin like “Better Search Replace” or a script like WP-CLI’s
wp search-replaceto avoid breaking serialized arrays. - Flush permalinks. If you get 404 errors on individual posts/pages but the home page loads, log in to your WordPress admin (if you can) and go to Settings → Permalinks. Click “Save Changes” without changing anything. This flushes the rewrite rules. If you can’t log in, you can manually reset the .htaccess file (for Apache) by deleting it and letting WordPress recreate it, or add the following to your nginx config if you’re using nginx:
location / { try_files $uri $uri/ /index.php?$args; } - Check file permissions. Incorrect file permissions can cause white screens or write errors. On the new server, set directories to 755 and files to 644. You can do this via FTP or SSH. For example, with SSH:
find /path/to/wordpress -type d -exec chmod 755 {} \; find /path/to/wordpress -type f -exec chmod 644 {} \; - Increase PHP memory limit. If you see a memory exhaustion error, edit wp-config.php and add:
define('WP_MEMORY_LIMIT', '256M'); - Enable WP_DEBUG to see errors. Add the following to wp-config.php to display PHP errors instead of a white screen:
define('WP_DEBUG', true); define('WP_DEBUG_DISPLAY', true);Then check the page for error messages. Once fixed, set WP_DEBUG back to false.
- Re-upload missing files. Sometimes the migration misses files (like .htaccess or the entire wp-content folder). Compare the file structure of your old and new sites. Ensure all themes, plugins, and uploads are present. If you used a migration plugin, re-run it or manually upload the wp-content folder.
- Test with a default theme. If your site still fails, temporarily rename the active theme folder in wp-content/themes (via FTP) to force WordPress to fall back to a default theme. This helps determine if the issue is theme-related.
Common Mistakes
- Forgetting to update the database host – many hosts use “localhost” but some use a remote hostname.
- Using the wrong database name or prefix – check that the table prefix in wp-config.php matches the one in your database (usually
wp_). - Not updating URLs in serialized data – a simple find-and-replace in SQL can corrupt serialized arrays, causing widget errors or broken menus.
- Copying files with hidden files excluded – some FTP clients skip .htaccess by default. Make sure you upload all hidden files.
- Ignoring PHP version differences – a site built on PHP 7.4 might not work on PHP 8.0 if plugins are outdated. Check your new server’s PHP version and update plugins if needed.
Tips
- Always take a fresh backup of both files and database before starting the migration.
- Use a migration plugin like Duplicator or UpdraftPlus to automate the process – they handle URL replacements and file transfers.
- If you’re moving domains too, update the DNS first and wait for propagation before doing the migration to avoid downtime.
- After the migration, test every key page: home, a post, a page, the admin dashboard, and a media file.
- Use a local development environment (like Local by Flywheel) to test the migrated site before going live.
Troubleshooting
If the steps above don’t resolve the issue, try these additional checks:
- Check the error logs. Look at the PHP error log on the new server (often in /var/log/ or in your hosting panel). This will give you the exact file and line number where the error occurs.
- Verify that the database is actually imported. Sometimes the import fails silently. Open phpMyAdmin and check that your tables have data (e.g., wp_posts should have rows). If empty, re-import the SQL file.
- Check for .htaccess conflicts. If you have custom rules in .htaccess, they might not work on the new server (e.g., if you moved from Apache to nginx). Remove or rewrite them.
- Disable security plugins. If you had a security plugin that blocks IPs, it might block your new server’s IP. Deactivate all plugins by renaming the plugins folder (wp-content/plugins) to plugins_old, then check if the site loads.
- Confirm the files are in the correct directory. On some hosts, WordPress must be in the public_html or www folder. If you placed it in a subfolder, you might see a directory listing instead of the site.
- Check the PHP version. If your site uses old PHP code, it may not run on PHP 8+. You can switch PHP versions in your hosting panel (cPanel, Plesk, etc.) to a lower version (e.g., 7.4) to see if that fixes it.
Frequently Asked Questions
Why do I get “Error establishing a database connection” after migration?
This usually means the database credentials in wp-config.php are incorrect, or the database server is unreachable. Double-check the host, username, password, and database name with your new host.
How do I fix the “Sorry, you are not allowed to access this page” error in wp-admin?
This often happens when the site URL in the database is wrong. Run the SQL update query for siteurl and home as shown in Step 4, or use WP-CLI: wp option update siteurl 'http://new-domain.com'.
My images are broken after migration. What should I do?
This is usually a URL issue. The image URLs in the database still point to the old domain. Use a search-replace tool to update all URLs in the database, not just the options table.
Can I migrate WordPress manually without a plugin?
Yes, you can export the database via phpMyAdmin, upload the files via FTP, and update wp-config.php. However, you must also replace URLs in the database, which is easier with a plugin or WP-CLI.
Why does my site show a directory listing instead of the WordPress page?
This means the server isn’t reading the .htaccess file (on Apache) or the index.php file is missing. Ensure .htaccess exists and contains the WordPress rewrite rules, or that index.php is in the root folder.
How do I fix a white screen after migration?
Enable WP_DEBUG to see the error message. Common causes are PHP memory limit, a fatal error in a plugin or theme, or missing files. Check the error log and increase memory limit if needed.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.