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.
- 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?
- With a pluginEasiestBetter Search Replace, from the dashboard. No SSH needed.
- With WP-CLIOne command over SSH. For people who use the command line.
- Not moved yetCopy with wp2wp.link, and links point to your domain afterwards.
Before you start
- A fresh database backup, for example with
wp db export before-replace.sql. - The old address exactly as the site used it, such as
http://localhost:8881. - Your new address, such as
https://example.com.
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.
Under Plugins → Add New Plugin, install Better Search Replace.
Under Tools → Better Search Replace, enter the old address and your new one.
Select all tables and run a dry run first.
It shows how many entries would change.
If the count looks right, run it again without the dry run.
Repeat for every variant of the old address you find.
For example
http://mysite.local, the address with a sub-folder, or the escaped formhttp:\/\/localhost:8881inside JSON.Clear your caching plugin, then the CDN if you use one.
Remove the plugin.
With WP-CLI
With SSH at your hosting, wp search-replace does the same in one command.
Try the replace as a dry run first.
wp search-replace 'http://localhost:8881' 'https://example.com' --all-tables --dry-runIf the count looks right, run it again without
--dry-run.Repeat for every variant of the old address you find.
For example
http://mysite.local, the address with a sub-folder, orhttp:\/\/localhost:8881inside JSON.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.
- Links written as plain text, for example in a privacy policy, are left as they are.
- A site that moves from a sub-folder to the domain itself may still need the path replaced with the steps on this page.
How you know it worked
- A new dry run for the old address finds nothing.
- Pages and images load from your domain, also after clearing the caches.
- You can log in at
/wp-adminwithout being sent to Localhost (local site) A WordPress site that runs on your own computer, in Studio, Local, XAMPP, MAMP or Docker. Its address, such as localhost:8080 , works only on that computer.. - Widgets, theme settings and builder pages look as before.
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.
Moving a site from your computer? wp2wp.link copies it, and afterwards the links point to your domain.
Start your moveFree · No account
Sources, checked 18 November 2026
WP-CLI search-replace, Better Search Replace, WordPress: Moving WordPress, Reprint, Reprint limitations.
Was this page helpful?
Thanks for letting us know.
Thanks for letting us know. What was missing or wrong? Write to benni@wp2wp.link, we read every message.