Reprint Relay Get started

Images and links still pointing to localhost after a migration

Short answer

The database still holds the old localhost or .local address. Replace it with Better Search Replace or wp search-replace, never with a plain text replace, then clear every cache.

Start your move

By wp2wp.linkUpdated 4 min read

Result
Links and images use your domain
You need
Admin login or SSH
Cost
Free
Do first
Back up the database

Which way fits you?

Before you start

Never replace in the SQL file: Serialized data The way WordPress stores some settings, such as widgets and theme options. The length of every piece of text is written next to it. stores the length of each text, as in s:21:"http://localhost:8881". If you change the address in a text editor, the length no longer matches. Then WordPress drops the value without a warning. Widgets vanish, theme settings reset, and page builders show empty pages. The tools on this page fix the lengths while they replace.

With a plugin

The free Better Search Replace plugin does the replace from the dashboard. Its dry run shows what would change, without changing anything.

  1. Under Plugins → Add New Plugin, install Better Search Replace.

  2. Under Tools → Better Search Replace, enter the old address and your new one.

  3. Select all tables and run a dry run first.

    It shows how many entries would change.

  4. If the count looks right, run it again without the dry run.

  5. Repeat for every variant of the old address you find.

    For example http://mysite.local, the address with a sub-folder, or the escaped form http:\/\/localhost:8881 inside JSON.

  6. Clear your caching plugin, then the CDN if you use one.

  7. Remove the plugin.

With WP-CLI

With SSH at your hosting, wp search-replace does the same in one command.

  1. Try the replace as a dry run first.

    wp search-replace 'http://localhost:8881' 'https://example.com' --all-tables --dry-run

  2. If the count looks right, run it again without --dry-run.

  3. Repeat for every variant of the old address you find.

    For example http://mysite.local, the address with a sub-folder, or http:\/\/localhost:8881 inside JSON.

  4. Flush the cache with wp cache flush.

    Then clear your caching plugin, and the CDN if you use one.

Not moved yet?

If you move the site with wp2wp.link, links and images point to your new address afterwards, so you can skip the replace.

How you know it worked

If something goes wrong

The login redirects to localhost

The cause is siteurl or home in wp_options, or WP_HOME / WP_SITEURL in wp-config.php. Set WP_HOME and WP_SITEURL to your domain in wp-config.php and log in. Then run the full replace.

Images are broken, links work

Page builder data or CSS files still hold the old address. Regenerate the builder’s CSS in its settings.

The address is fixed, but the page still shows it

A cache serves the old page: a caching plugin, the host’s cache or a CDN. Clear each of them.

The browser warns about mixed content

Your https:// site still has http:// links. Replace the http:// form of your address too.

The sub-folder is still in the links

The site moved from localhost/mysite to the domain itself. Replace the whole old address, including the folder.

Questions

Where does WordPress keep the old address?

In the database table wp_options: siteurl, home, and widget, theme and plugin settings. In wp_posts: content, block attributes and GUIDs. Also in wp_postmeta: page builder data from Elementor, Divi or Beaver Builder and custom fields, often as JSON or serialized arrays. CSS files that themes and plugins create with full addresses can hold it too.

Do I need to change the GUIDs?

On a site that was already public, WordPress advises against it, because feed readers use the GUIDs. If the site was never public, you can replace them too.

Sources, checked 18 November 2026

WP-CLI search-replace, Better Search Replace, WordPress: Moving WordPress, Reprint, Reprint limitations.

Was this page helpful?

Back to top