Blog · WebJi® India

Move WordPress from Localhost to a Live Server

Quick answer: To move WordPress from localhost to a live server, copy the files, create an empty database, import the local database, and edit wp-config.php with the live database name and user. Replace the localhost URL with a tool that understands serialised PHP. Save permalinks. Point the domain only after a temporary URL opens the site.
✓ In business since 2005✓ INR + GST billing✓ 24/7 Email Support — avg reply < 60 min
Modern data center corridor in India with rows of server racks under cool blue-white lighting — move wordpress from localhost to server

What You Need on the Live Server Before the Move

Create an empty database and a user in the hosting panel, then note four values: database name, user, password and host. The host is often the word localhost even on a live server, where it means the database sits on the same machine as PHP rather than on your laptop.

Also note the web root, usually public_html, and the PHP and MySQL versions. If the local site runs PHP 8.2 and the host defaults to 8.1, switch the live account before importing so the first page load is not a fatal error.

Modern data center corridor in India with rows of server racks under cool blue-white lighting — move wordpress from localhost to server

Step 1: Export the Local Files and Database

Zip the local WordPress folder, then export the database as one .sql file. Keep both in the same folder and name them with the date so this copy is not confused with an older backup.

  1. Stop the local site and remove cache folders such as wp-content/cache from the copy you are about to zip.
  2. Zip the whole WordPress directory, including wp-content. Leave out node_modules and any local backup folder.
  3. Open phpMyAdmin, select the WordPress database, choose Export, method Quick, format SQL, and save the file.
  4. Or run one command from the site root: wp db export local.sql.
  5. Check the export: open the .sql file and confirm it contains CREATE TABLE and INSERT statements, not just a header.

Step 2: Import the Database and Set wp-config.php Credentials

Create the database on the live server, import the .sql file, then point wp-config.php at it. Five values must match exactly, and a single wrong character produces the same database-connection error.

  • DB_NAME — the live database name, usually prefixed with your hosting username, such as user_wp.
  • DB_USER — the MySQL user you added to that database.
  • DB_PASSWORD — the password set for that user.
  • DB_HOST — usually localhost; a managed host may give an IP address or a socket path.
  • $table_prefix — must match the prefix inside the imported file, wp_ unless you changed it.
  1. In the hosting panel create a database and a user, then add the user to the database with all privileges.
  2. Upload the zipped files to the web root and extract them there.
  3. In phpMyAdmin select the new database, choose Import, and upload the .sql file.
  4. If the upload fails on file size, gzip the file, raise upload_max_filesize, or import it table group by table group.
  5. Edit wp-config.php with the live values and save the file.
  6. Load the site on the temporary URL. "Error establishing a database connection" means one of the five values is wrong, not that the import failed.

Step 3: Search-Replace the Localhost URL Safely

Replace every local address with the live domain using a tool that understands serialised PHP. WordPress stores widget, menu and theme settings as serialised strings that carry their own character count, and a plain text-editor replace changes that count and corrupts them.

  • What to replace — http://localhost, http://localhost:8080 (or 1880 on Local), and any folder path such as http://localhost/mysite.
  • What to replace it with — https://example.com, with no trailing slash.
  • Where it lives — wp_options (siteurl and home), post content, and postmeta.
  1. Take a fresh database backup before touching any URL.
  2. Run a dry run from the site root: wp search-replace 'http://localhost:8080' 'https://example.com' --dry-run.
  3. Read the table report, then run the same command without --dry-run.
  4. Repeat once for any second local address, such as a folder path or an old domain.
  5. Without SSH, use Better Search Replace and leave its dry-run option ticked first.
  6. Verify: open Settings → General and confirm both URL fields show the live domain.

The WordPress URL search-replace guide covers the same commands for a domain change rather than a localhost move.

Step 4: Point DNS and Enable SSL on the Live Domain

Lower the DNS TTL a day before the move, point the domain at the new host, then issue SSL once the domain resolves there. Forcing HTTPS before the certificate exists gives every visitor a browser warning.

  1. Set the TTL on the existing A record to 300 seconds and wait for the old TTL to expire.
  2. Change the A record to the new server IP, or switch the nameservers to the host's pair. Do one, not both.
  3. Check from a network other than your own: dig example.com +short should return the new IP.
  4. Issue the certificate from the hosting panel, through AutoSSL or Let's Encrypt, once the domain resolves.
  5. Turn on the HTTPS redirect and load the site over https.
  6. Verify: the padlock appears and the browser console shows no mixed-content warning.

DNS can take from minutes to a few hours, and the DNS propagation explainer covers why. Certificate installation is covered in installing SSL in cPanel.

Step 5: Test the Moved Site Before You Announce It

Open the live domain in a private window and work through this list once. Each item catches a different kind of breakage that a glance at the homepage will miss.

  1. Homepage loads over https with images and fonts in place.
  2. An inner page and a blog post open without a 404.
  3. Log in at /wp-admin with the existing username and password.
  4. Settings → Permalinks shows the intended structure; click Save Changes once to rebuild rewrite rules.
  5. Upload one image in the media library and confirm it displays.
  6. Submit the contact form and confirm the email arrives.
  7. Open a menu and a widget to confirm the serialised settings survived the replace.
  8. Search the site and confirm results load.
  9. Open a URL that does not exist and confirm the 404 page appears.
  10. Check the browser console for mixed content, then submit the sitemap in Search Console.

When to Use a Migration Plugin Instead

Use a migration plugin when the local site can run one and the package fits the host's upload limit. It rewrites URLs during import and skips the manual credential step, but it still needs the same test list above.

Delete the installer and any package file the plugin leaves in the web root once the import finishes. The manual path on this page is for when the plugin will not run, when the site is too large for the host's import limit, or when you want to see every change.

Frequently Asked Questions

How do I move WordPress from localhost to a live server?

Export the files and database, import the database on the live host, set the database constants in wp-config.php, replace the localhost URL with a serialisation-safe tool, then save permalinks and point DNS.

Why do menus break after a search-replace?

A text-editor replace changes the character count inside serialised PHP strings, so WordPress reads the stored menu and widget data as corrupt. A serialisation-aware tool updates the count as well.

Should I point the domain before or after the move?

After. Open the copy on a temporary URL, confirm login, images and forms, then change DNS and issue SSL. Pointing the domain first sends real visitors to a half-moved site.

Can I move only the database?

Not on its own. The database holds the text and settings, while wp-content holds uploads, themes and plugins. Copy both, or the site will render without images and styling.

What if my local site runs on a port like localhost:8080?

Replace the full string including the port, http://localhost:8080, with the live https URL. Run a dry run first, because the port string also appears inside serialised options.

Is WebJi® an Indian company?

Yes. WebJi® is headquartered in Jaipur, Rajasthan and has operated since 2005. Billing, support and governance all run from India.

Need help with this?

WebJi® support does it for you — free. Talk to our Jaipur team →