Move WordPress from Localhost to Server: Full Guide
In this article
To move WordPress from localhost to a live server, you need to transfer your files and database, then update the site URL references. This guide walks you through the entire process step by step, covering both manual and plugin methods, and how to fix common issues.
Why Move WordPress from Localhost to a Server?
Developing a WordPress site on localhost (your computer) is great for testing themes, plugins, and custom code without affecting a live site. But when you're ready to launch, you need to move it to a web server so the public can access it. Reasons include:
- Going live with a new website or blog
- Client projects that need to be deployed
- Taking advantage of server features like better performance, uptime, and security
- Collaborating with a team that needs access to the site
What You Need Before Starting
Before you begin, make sure you have the following:
- Access to your localhost installation (typically via phpMyAdmin or a local server tool like XAMPP, MAMP, or Local by Flywheel)
- An FTP client (like FileZilla) or a file manager in your hosting control panel
- Your hosting account credentials (cPanel, Plesk, or similar)
- A domain name pointed to your server (or you can use a temporary URL)
- Your WordPress admin credentials for both local and remote sites
Step-by-Step Manual Migration
This method gives you full control and doesn't require extra plugins. It involves three main steps: backing up, transferring, and updating.
1. Export Your Local Database
Log into your local phpMyAdmin (usually at http://localhost/phpmyadmin). Select your WordPress database, click the "Export" tab, and choose the "Quick" or "Custom" method. The default settings are fine; download the .sql file.
2. Upload Your WordPress Files
Using an FTP client, connect to your server and navigate to the public_html (or www) directory. Upload all the files from your local WordPress folder (including the hidden .htaccess file if you have one). This can take a while depending on your connection speed.
3. Create a New Database on Your Server
In your hosting control panel (e.g., cPanel), find the MySQL Databases section. Create a new database, a new user, and assign that user to the database with all privileges. Note the database name, username, and password.
4. Import Your Database
Open phpMyAdmin on your server, select the new database, click the "Import" tab, choose your .sql file, and click "Go". This will copy all your content, settings, and users.
5. Update wp-config.php
Navigate to your server's WordPress directory and edit wp-config.php. Replace the database connection details with the ones you created in step 3:
define('DB_NAME', 'your_new_db_name');
define('DB_USER', 'your_new_db_user');
define('DB_PASSWORD', 'your_new_db_password');
define('DB_HOST', 'localhost');Save the file.
6. Update Site URLs
Your local site URLs are like http://localhost/mysite, but your live site is at http://www.yourdomain.com. You need to update the siteurl and home options in the database. The safest way is to use a SQL query in phpMyAdmin:
UPDATE wp_options SET option_value = 'http://www.yourdomain.com' WHERE option_name = 'siteurl'; UPDATE wp_options SET option_value = 'http://www.yourdomain.com' WHERE option_name = 'home';
Replace wp_ with your table prefix if it's different. Also, if you have a lot of hardcoded URLs (like in content), you'll need to replace them too. A plugin like "Better Search Replace" can do this safely.
7. Fix Permalinks
Log into your WordPress admin (at http://www.yourdomain.com/wp-admin), go to Settings > Permalinks, and click "Save Changes" to flush the rewrite rules. This prevents 404 errors on your pages.
Using a Migration Plugin
If the manual process seems daunting, plugins like Duplicator, All-in-One WP Migration, or UpdraftPlus can automate most of it. Here's a typical process with Duplicator:
- Install and activate the plugin on your local site.
- Create a package (it bundles your files and database into a zip).
- Upload the package and the installer.php file to your server.
- Run the installer script in your browser and follow the prompts.
- Enter your new database details when asked.
- Update the site URLs if the plugin doesn't do it automatically.
These plugins often handle URL replacements and file permissions for you, making the process less error-prone.
Common Problems and How to Fix Them
- 404 errors on pages: Go to Settings > Permalinks and click "Save Changes". If that fails, check that your .htaccess file is present and writable.
- Database connection error: Double-check your wp-config.php credentials. Ensure the database user has the correct privileges.
- Mixed content warnings (http/https): If your server uses SSL, you'll need to update URLs to https. Use a search-replace tool to change all instances of http:// to https://.
- Images not loading: This is usually a URL issue. The image paths in the database still point to localhost. Run a search-replace for your local URL to your live URL.
- Login redirects back to localhost: This happens when the siteurl and home options are not updated correctly. Use phpMyAdmin to update them directly.
- File permissions errors: Set file permissions to 644 and directory permissions to 755. In cPanel, you can do this via the File Manager.
Comparing Manual vs. Plugin Migration
Manual migration gives you complete control and doesn't require installing extra plugins, but it's more technical and time-consuming. Plugin migration is faster and easier for beginners, but you need to trust the plugin and sometimes it can leave behind temporary files. Both methods work; choose based on your comfort level.
Post-Migration Checklist
- Visit your site's homepage and a few inner pages to ensure everything loads.
- Test the login page and log in.
- Check that all images and media files display correctly.
- Test forms, comments, and any e-commerce functionality.
- Update your permalinks and clear any caching plugins.
- Verify that your domain's DNS is correctly pointing to the new server.
Frequently Asked Questions
Do I need to change my localhost URLs in the database?
Yes, absolutely. The database stores absolute URLs. If you don't change them, your site will try to load resources from localhost, which won't work on the server. Use a search-replace tool or SQL queries to update them.
Can I move WordPress from localhost to a subdirectory?
Yes, you can. The process is the same, but your site URL will be something like http://www.yourdomain.com/subdirectory. Just replace the URL in the database accordingly.
What if my localhost is not at the root (e.g., localhost/mysite)?
This is common. The key is to update the siteurl and home options to the new live URL. Also, any absolute paths in your content (like images) need to be updated. A search-replace plugin is your friend here.
How long does the migration take?
It depends on the size of your site and your internet connection. A small site can take 15-30 minutes manually. Using a plugin can be faster, but the upload time for files is the same.
Will I lose my site's SEO ranking after moving?
If you do a proper 301 redirect from your old domain (if changing) and keep the same URL structure, you should not lose rankings. If you're moving from localhost to a new domain, there's no old site to redirect, so you're starting fresh.
Is it safe to delete my localhost site after moving?
Yes, but it's a good idea to keep a backup for a while. Once you confirm the live site works perfectly, you can delete the local files to free up space.