Move WordPress from Localhost to a Live Server
To move WordPress from localhost to a live server, upload the WordPress files, import the local database into a new empty database, and put the live database name, user, password and host in wp-config.php. Replace the localhost URL with WP-CLI search-replace or a serialization-safe plugin, re-save permalinks, and point the domain only after testing.
For developers and site owners who built a WordPress site on XAMPP, MAMP or Local and now need it running on real hosting.
knowledge
- Read time
- 5 min
- Sections
- 8
- Updated
- 14 Nov 2026
- Written by
- WebJi® team
Last editorial update: 14 November 2026. Prices follow the dated sources on this page; checkout confirms current charges.
What moving WordPress from localhost to live involves
Moving WordPress from localhost to a live server means copying two things, the files and the database, then telling WordPress its new database login and its new address. Nothing else on the server needs to change, and every step can be checked on a temporary URL before the domain points at it.
Start by noting the exact local address, because that string is what you will replace later. It depends on the tool you built the site with:
| Local tool | Typical site address | Database access |
|---|---|---|
| XAMPP / WampServer | http://localhost/mysite | phpMyAdmin at http://localhost/phpmyadmin |
| MAMP | http://localhost:8888/mysite (default port) | phpMyAdmin from the MAMP start page |
| Local (by WP Engine) | http://mysite.local | Adminer from the Database tab; WP-CLI via "Open site shell" |
| wp-env (Docker) | http://localhost:8888 | npx wp-env run cli wp db export |
Building a local copy in the first place is covered in installing WordPress on XAMPP.
What you need on the live server before the move
Create an empty database and a database user in the hosting panel, give the user all privileges on it, and note four values: database name, user, password and host. On most shared hosting the host is localhost, meaning the database runs on the same server as PHP, not on your laptop.
- Web root: usually
public_html, or the addon domain's folder. - PHP version: match the local version or newer; switch it in the panel before the first page load.
- Database collation: a dump from MySQL 8 may use
utf8mb4_0900_ai_ci, which older MariaDB servers reject with "Unknown collation". Replace it withutf8mb4_unicode_ciin the.sqlfile before importing if the host runs MariaDB. - Upload limits: check the phpMyAdmin import limit; large dumps may need the large SQL import method.
Step 1: export the local files and database
Zip the whole WordPress folder including wp-content, and export the database to a single .sql file, named with the date so it cannot be confused with an older backup.
- Delete cache folders such as
wp-content/cachefrom the copy, and leave outnode_modulesand local backup folders. - Zip the WordPress directory.
- In phpMyAdmin, select the database → Export → Quick → SQL, or run
wp db export local-2026-11-14.sqlfrom the site root. - Open the
.sqlfile and confirm it containsCREATE TABLEandINSERTlines, not just a header.
Step 2: upload the files, import the database and edit wp-config.php
Upload and extract the zip in the web root, import the .sql file into the new empty database, then put the live database credentials in wp-config.php.
define( 'DB_NAME', 'cpuser_wp' );
define( 'DB_USER', 'cpuser_wpuser' );
define( 'DB_PASSWORD', 'the-password-you-set' );
define( 'DB_HOST', 'localhost' );
$table_prefix = 'wp_'; // must match the prefix in the imported tables
On cPanel, database and user names carry your account prefix, as shown in creating a MySQL database in cPanel. If the site then shows "Error establishing a database connection", one of these five values is wrong, not the import; fixing the database connection error lists the checks. Upload over SFTP or File Manager; uploading a website by FTP covers FileZilla.
Step 3: replace the localhost URL without breaking serialized data
Replace every copy of the local address with the live one using WP-CLI or Better Search Replace, never a text editor, because WordPress stores many settings as serialized strings that record their own length. A plain find-and-replace changes the text but not the stored length, and menus, widgets and theme options vanish.
# preview, then run; include the port or folder exactly as used locally
wp search-replace 'http://localhost:8888/mysite' 'https://www.example.in' --skip-columns=guid --dry-run
wp search-replace 'http://localhost:8888/mysite' 'https://www.example.in' --skip-columns=guid
# if you can only run SQL, import with WP-CLI instead of phpMyAdmin
wp db import local-2026-11-14.sql
Run the command once more for any second form of the address, such as an escaped JSON version some page builders store (http:\/\/localhost). Then confirm Settings → General shows the live URL in both fields. Other ways to set those two fields are in changing the WordPress site URL, and WordPress search-replace for URLs covers the tool options.
Step 4: point the domain and turn on SSL
Point the domain at the live server only after the site works on a temporary URL, then issue the SSL certificate once DNS resolves there, and only then force HTTPS. Forcing HTTPS before the certificate exists shows every visitor a browser warning.
- A day ahead, lower the A record's TTL to 300 seconds if you are changing an existing record.
- Change the A record to the server's IP, or switch to the host's nameservers; do one, not both. See pointing a domain to hosting.
- Check from another network with
dig +short example.in; propagation is explained in DNS propagation. - Issue the certificate with AutoSSL or Let's Encrypt in the panel (installing SSL in cPanel), then enable the HTTPS redirect.
Step 5: test the live site before announcing it
Work through one checklist in a private window; each item catches a different kind of breakage that a glance at the homepage misses.
- Homepage, an inner page and a post load over HTTPS with images and fonts.
- Log in at
/wp-adminwith the local username and password. - Re-save Settings → Permalinks once to rebuild rewrite rules.
- Upload an image and confirm it displays (tests folder permissions: 755 folders, 644 files).
- Submit the contact form and confirm the email arrives; live mail often needs SMTP set up.
- Open a menu, a widget and a page-builder page to confirm serialized settings survived.
- Browser console shows no mixed-content warnings; then submit the sitemap in Search Console.
- Turn off "Discourage search engines" in Settings → Reading if it was ticked locally.
A migration plugin can automate Steps 1–3 when the package fits the host's upload limit; delete its installer files afterwards. If you would rather not do it yourself, the WebJi® website migration service moves one site with up to 5 databases (up to 5 GB) for ₹700 before 18% GST, and WebJi® WordPress hosting includes free migration guidance.
Frequently asked questions
Why do menus and widgets disappear after the move?
The URL was replaced with a text editor or raw SQL, which changed the characters inside serialized strings without updating their stored length. Re-import the original dump and replace the URL with WP-CLI search-replace or Better Search Replace, which recalculate the lengths.
The live site redirects me back to localhost. What happened?
The siteurl and home options still hold the local address, or WP_HOME and WP_SITEURL are hard-coded in the copied wp-config.php. Remove or correct the constants, run the search-replace, and clear the browser cache, which may have stored the redirect.
Can I move only the database and reinstall WordPress on the server?
Only if you also copy wp-content. The database holds text and settings, while wp-content holds uploads, themes and plugins. A fresh core install plus the old wp-content and database works; the database alone gives a site without images or design.
Should I test on a temporary URL first?
Yes. Many hosts provide a temporary or preview URL, or you can map the domain to the new IP in your computer's hosts file. Test login, images and forms there before changing DNS so visitors never see a half-moved site.
Checked 14 November 2026 against the WP-CLI command reference · Migration price from WebJi®'s published pricing, checked 14 November 2026 · Reviewed by the WebJi® team, Jaipur.
Ready to get started with WebJi®?
Join 12,000+ businesses across India and overseas. INR pricing, 18% GST shown before payment and 24/7 email support in Hindi and English — average first reply under 60 minutes.