Contact

Web Design

Moving WordPress from Localhost to a Live Server

To move WordPress from localhost to a live server, you transfer the files and database, update wp-config.php and replace every form of the local URL with the live one. This guide shows how to do it step by step without breaking serialized data.

Illustration of a WordPress site moving from a local computer to a live server along with its database and links
Contents

This guide is for freelance developers and agency teams who build sites in XAMPP, MAMP, Local or Docker and then launch them on a client's domain, and for site owners who set WordPress up on their own laptop first. If everything works perfectly locally but the live site shows broken images, logins that bounce you back, or theme settings that reset themselves, the cause is nearly always the same: local URLs, file paths and the table prefix baked into the database. Below we cover pre-launch preparation, moving files and the database, every form the local URL takes, and the checks to run after launch.

What does it mean to move WordPress from localhost to live?

Running WordPress on localhost means running the site on a web server, PHP and MySQL/MariaDB on your own computer instead of on a server reachable from the internet. Going live means moving that same site, with its content and settings, to a real domain and server and opening it to visitors. Technically it resembles a host-to-host migration; the difference is that the source address only makes sense on your machine.

WordPress stores the site address in two settings (siteurl and home), but the real weight sits in the content: image links in posts, menu items, page builder data, widget settings and plugin options all contain the full URL. Knowing exactly what your local URL looks like is therefore the first step of any launch.

Common local setups and their URLs

Typical URLs and file locations in local development environments
EnvironmentTypical URLWhere files liveWhat to watch
XAMPP (Windows)http://localhost/site, often localhost:8080 when port 80 is takenC:\xampp\htdocs\siteSubfolder and Windows paths end up in the database
MAMP (macOS)In many setups http://localhost:8888/site/Applications/MAMP/htdocsThe port is part of every stored URL
Local (LocalWP)A local domain such as http://site.localLocal Sites/site/app/publicSearch for the local domain in every form, too
Docker (official wordpress image)Usually published as http://localhost:8080/var/www/html inside the containerThe database lives in a container; export it with WP-CLI or mysqldump

If you reach your dashboard at "localhost/wordpress/wp-admin", the site is installed in a subfolder (/wordpress). If it will live at the domain root, the subfolder has to disappear from every URL as well, which takes more care than swapping the hostname.

Localhost or staging?

Localhost runs only on your machine, so you can't show it to a client or test real server conditions. A staging environment is a copy that mirrors the live server, is reachable online and is kept out of search engines. Many teams build locally, move to staging for client sign-off, then go live. The method in this article is the same for both hops; only the target URL changes.

What should you prepare before going live?

Pre-launch preparation means clearing out everything that should stay local and fixing the settings that would cause trouble on the server. Every bit of test data you move will exist on the live site too, so cleaning up before the move is far easier than after it.

Checklist of tasks to complete before taking a WordPress site live
Cleaning up before the move saves hours on the live site.

Clean up locally

  • Test content: the "Hello world" post, the sample page, test comments, lorem ipsum and abandoned drafts.
  • Unused plugins and themes: delete inactive ones; each adds to the migration size and to the attack surface.
  • Revisions and spam comments: long build phases bloat the database for no benefit.
  • Test accounts: remove the user called "admin", throwaway accounts and simple passwords. Every administrator on the live site needs a strong, unique password.
  • Debugging: set WP_DEBUG to false in wp-config.php and delete any debug.log.

Check the settings

  • Permalinks: settle the structure under Settings > Permalinks while you are still local. Changing the permalink structure after launch creates redirect work you don't need.
  • Search engine visibility: the "Discourage search engines from indexing this site" box under Settings > Reading can stay ticked locally and on staging. Untick it only at launch, on the live server. Unticking it too early lets a test copy get indexed; forgetting it keeps the real site invisible.
  • Email and forms: replace test recipients and SMTP settings with the real ones.
  • Backup: take a full backup of the local site before you move anything. We compare the options in our WordPress backup and restore guide.

How do you move the files and the database?

A manual launch has three parts: upload the files, move the database and adapt wp-config.php to the new environment. The URL replacement comes after these three, and keeping that order makes everything simpler.

Diagram of the six steps for moving a WordPress site from localhost to a live server
The URL replacement comes after the files and database are in place.
  1. Create a database on the server: in your hosting panel, create an empty database and a user with full rights to it. Note the name, user, password and host.
  2. Upload the files: upload the whole local folder (WordPress core, wp-content, .htaccess) over SFTP, or zip it and upload it through the hosting panel. Make sure hidden files come along.
  3. Export the database: use the Export tab in phpMyAdmin or run wp db export local.sql.
  4. Import the database: use phpMyAdmin on the server or wp db import local.sql. Large files may hit the hosting panel's upload limit; a compressed file or the command line gets around that.
  5. Update wp-config.php: set DB_NAME, DB_USER, DB_PASSWORD and DB_HOST to the live values, make sure $table_prefix matches the tables you imported, and regenerate the security keys.
  6. Replace the URLs: switch the local address to the live one using the method in the next section.

This flow is almost identical to moving between two hosts, which we cover step by step in our guide to migrating WordPress to a new host. What makes a localhost launch different is that the source URL contains parts that never exist on a live site: a port, a subfolder and plain http.

In what forms is the local URL stored in the database?

The local URL isn't stored in one form; the same address appears in at least four spellings depending on the content type, and each needs replacing. Say you built a site for an architecture studio at http://localhost:8080/studio and are moving it to https://examplestudio.com. You will find:

Cards showing five different forms in which the localhost URL is stored in the database
The same address sits in the database in several forms, and each must change.
  • Plain: http://localhost:8080/studio/wp-content/uploads/... (classic editor content, menus, settings)
  • Protocol-relative: //localhost:8080/studio (links some themes and plugins write without a scheme)
  • JSON-escaped: http:\/\/localhost:8080\/studio (Gutenberg block attributes and Elementor data)
  • URL-encoded: http%3A%2F%2Flocalhost%3A8080%2Fstudio (share links, some form and redirect data)

Replace only the plain form and the site looks fine at first glance, yet background images on Elementor pages and links inside blocks still point at localhost. You only notice when a visitor's browser fails to load them.

Why does a plain SQL REPLACE break serialized data?

Serialized data is how PHP stores arrays and objects as text, and it records the length of every string. s:21:"http://localhost:8080"; means "a string of 21 characters". Run UPDATE wp_options SET option_value = REPLACE(option_value, 'http://localhost:8080', 'https://example.com') in phpMyAdmin and the string becomes 19 characters long while the 21 in front of it stays. PHP can no longer read the value, WordPress treats the option as empty, and theme options, widgets or plugin settings fall back to their defaults. Because there is no error message, people often notice days later.

Replacing safely with wp search-replace

WP-CLI's wp search-replace command unpacks serialized values, replaces inside them and recalculates the lengths. If you have SSH access to the server, this is the recommended route:

  1. Start with a dry run: wp search-replace 'http://localhost:8080/studio' 'https://examplestudio.com' --dry-run. It changes nothing and lists how many replacements each table would get.
  2. If the numbers make sense, run it without --dry-run. Since the site was never public, changing the GUID column does no harm, though many guides add --skip-columns=guid anyway.
  3. Run it again for the JSON-escaped form: wp search-replace 'http:\/\/localhost:8080\/studio' 'https:\/\/examplestudio.com'.
  4. Add --all-tables if you have tables without the WordPress prefix, then confirm nothing is left with wp db search 'localhost:8080'.

No SSH on the live server? Do the replacement locally and write the result to a file: --export=live.sql produces an SQL file with the new URLs without touching your local database. Import that file on the server and you're done.

Table comparing a plain SQL REPLACE with WP-CLI wp search-replace on five criteria
The difference lies in recalculating string lengths in serialized data.

How do you handle Windows paths and table prefixes?

Besides URLs there are two quiet problems: server paths and the table prefix. Neither causes trouble locally, and both surface in odd places once you're live.

Server paths

Some plugins store the absolute path of their cache, log or upload folder in the database. Locally that path is something like C:\xampp\htdocs\studio; on the server it's /home/user/public_html. Windows uses backslashes and Linux forward slashes, so search for the path in both forms; inside JSON the backslashes may also be doubled (C:\\xampp\\htdocs). Linux file names are case-sensitive, too: Logo.PNG opens fine on Windows when the content asks for logo.png, and becomes a broken image on the server.

Table prefix

One-click installers in hosting panels usually pick a random prefix (for example wp7k_), while your local site most likely uses wp_. The simplest fix is to set $table_prefix in wp-config.php to match the tables you imported. If you do want to change the prefix, renaming the tables isn't enough: the wp_user_roles row in the options table and the wp_capabilities and wp_user_level keys in usermeta must carry the new prefix too. Otherwise you'll log in with the right password and still be told you aren't allowed to access the dashboard.

How do you go live with Doruva Migrate?

Doruva Migrate, Doruva's free plugin, automates the URL, path and prefix part of the steps above. Locally, Export > Export site puts the database, media, themes and plugins into a single .doruva archive, and you can leave out revisions, spam comments and inactive plugins and themes. On the live server, install a clean WordPress, activate the plugin and drop the archive onto the Import screen.

Doruva Migrate Import screen: a drop zone for the .doruva file and a picker for an existing backup
Import: drop the archive and it uploads in small chunks; nothing changes until you confirm.
  • URL adaptation: addresses with a port such as localhost:8080, subfolders and the switch from http to https are adapted automatically, with plain, protocol-relative, JSON-escaped and URL-encoded forms replaced together. Server paths are replaced with forward and back slashes, so a Windows-to-Linux move is covered.
  • Serialization and prefix: serialized data is parsed at byte level and string lengths are recalculated. The table prefix is converted to the target's prefix together with user roles and capability keys.
  • Safe import: the archive uploads in 2–5 MB chunks, so the server's upload limit doesn't get in the way. The database goes into temporary tables first and is switched live in one move at the end.
  • Change summary: at the end you see a summary such as "localhost:8091 → https://client.com, 4,383 replacements in 7 tables", with per-table and per-column detail. Permalinks, caches and Elementor CSS are refreshed automatically.

Users come from the archive after the import, so you log in with your local username and password. Base64-encoded data and root-relative links such as /studio/contact are not replaced; if you moved from a subfolder to the root, find and fix them with the plugin's Find & Replace tool, starting with a dry run. The plugin is free and coming soon to WordPress.org; features change between versions, so check the current list on the product page. You can also see it alongside Doruva SEO on the Doruva WordPress plugins page.

What should you check after launch?

The first hour after launch is the best time to catch problems before visitors do. Work through this list in a private browser window, then once more on a phone.

  1. Login and dashboard: log in at /wp-admin and confirm that WordPress Address and Site Address under Settings > General show the live URL.
  2. Permalinks: open Settings > Permalinks and save without changing anything; the rewrite rules are rebuilt and most 404s on inner pages disappear.
  3. HTTPS and mixed content: check the certificate is valid, the browser shows no warning, and the page source no longer loads anything from localhost or plain http://.
  4. Search engine visibility: untick the discourage box under Settings > Reading and make sure robots.txt doesn't block the site.
  5. Forms and email: send a real message through the contact form and confirm it arrives.
  6. Sitemap and Search Console: confirm that /wp-sitemap.xml or your SEO plugin's sitemap loads, and submit it in Search Console.
  7. Caching and speed: reconfigure your caching plugin and CDN, then measure the home page speed.

For the SEO side, follow our WordPress SEO settings guide, and for a broader pass, our technical SEO checklist. To see quickly how the site looks from the outside, our free SEO checker covers titles, meta tags and the technical basics in one report.

Common mistakes

Most localhost launch problems come down to a handful of repeat mistakes. Picture a small team launching a medical clinic's site: it opens fine, but the next day they find the theme settings reset, the booking form not sending email and Google unable to see the site. Each of those three problems is on this list.

  • Running a plain REPLACE in phpMyAdmin: it breaks serialized settings. Always use a tool that understands serialization.
  • Replacing only the word "localhost": the port and subfolder stay behind and you end up with dead URLs like https://example.com:8080/studio. Always replace the full old URL with the full new URL.
  • Forgetting the JSON-escaped form: Gutenberg blocks and Elementor pages keep pointing at localhost.
  • Forgetting the visibility box: the site is live but closed to search engines.
  • Collation mismatch: if you run MySQL 8 locally, tables may be exported with utf8mb4_0900_ai_ci, which older MariaDB versions on shared hosting don't recognise, and the import fails. Check the server version before you export.
  • Leaving the SQL file on the server: a database dump left in public_html is a file anyone can download. Delete it once the import is done.

Summary and next steps

Going live from localhost comes down to a clean local site, a complete transfer of files and database, a correct wp-config.php and a URL replacement that covers every form. Replace URLs with a serialization-aware tool and start with a dry run; then deal with paths, the table prefix and the post-launch checks. Follow that order and a launch becomes a planned job of a few hours.

If you'd like a professional team to handle the site from design to server setup, take a look at our web design services. Tell us about your project and your launch timeline, and we'll plan it together.

Frequently Asked Questions

Why can't I reach localhost/wordpress/wp-admin?

Usually the local web server or MySQL isn't running, or the site runs on another port such as localhost:8080. Check that the services are started in your local tool and that the URL includes the right port.

After launch, logging in sends me back to localhost. Why?

The siteurl and home settings in the database still hold the local address. Fix those two values with wp option update or in the options table, then replace the URLs in your content with a serialization-safe tool.

When should I untick "Discourage search engines"?

Once the site is open on its live domain and your final checks are done. Keeping it ticked locally and on staging is right; forgetting it on the live site keeps you out of search results.

Do I need to change the local table prefix?

No. The easiest option is to set $table_prefix in the live wp-config.php to match the tables you imported. If you do change the prefix, the user role and capability entries must be updated too.

Can I use wp search-replace without SSH on the server?

Yes, indirectly. Run the replacement on your own machine with the --export option to produce an SQL file with the new URLs, then import that file on the server through phpMyAdmin.

Let’s apply this to your project.

Let’s look together at how the approach in this article applies to your own website, search visibility or digital systems.