On this page
What this issue is
A staging site is a private copy of your website used for testing. Localhost is the address of a developer's own computer. When a page is copied from one of these to your live site, image links can be copied with it as full addresses. The live page then asks the visitor's browser to fetch images from staging.example.com or localhost.
Why it costs you leads or sales
Broken images on a landing page, product page or checkout make the page look unfinished or unsafe. Hero images, product photos, logos and trust badges carry much of the persuasion. When they vanish, fewer visitors fill in the form or add to cart.
- Ad or search clickVisitor reaches the live page
- Page loadsHTML and text appear
- Image requestPoints to staging or localhost, fails
- Visitor trustPage looks broken, visitor leaves
- Form or purchaseNever reached
The page loads, but the image request goes to a staging address and fails.
How to check if your site has it
Open the page in a private window
Use a window where you are not logged in to your CMS, ideally on mobile data. Look for gaps, empty boxes or alt text where images should be.
Open DevTools Network tab
Press F12, open Network, tick Disable cache, filter by Img and reload. Red rows or failed requests show the broken image URLs and their domains.
Search the page source
Press Ctrl+U (Cmd+Option+U on Mac) and search for
localhost,127.0.0.1,staging,dev.and.local. Checksrc,srcset,data-srcand inlinebackground-imagestyles.Check the Console
Look for errors such as net::ERR_CONNECTION_REFUSED (localhost) or mixed content warnings naming the image.
Check CSS and meta tags
Open your stylesheets and the og:image tag as well. Background images in CSS and social preview images are often missed.
curl -s https://www.example.com/your-page/ | grep -Eo '(src|srcset|data-src|href|content)="[^"]*(localhost|127\.0\.0\.1|staging|\.local)[^"]*"'How to fix it
The cause is almost always full URLs stored in content or settings at the time of copying. Replace the old domain with the live one, then clear every cache layer. Take a backup before any bulk change.
Back up the database
Use your host's backup or a backup plugin before changing anything.
Run a search and replace
With WP-CLI, run a dry run first, then the real replace. A plugin such as Better Search Replace also works. Serialized data is handled correctly by these tools; do not use a plain SQL REPLACE on it.
Check settings and builders
In Settings > General, confirm WordPress Address and Site Address are the live domain. Re-save Elementor, Divi or other builder pages, and regenerate their CSS files.
Clear caches
Purge your caching plugin, server cache and CDN.
Find hard-coded URLs in the theme
In Online Store > Themes > Edit code, search for localhost and staging across files. Replace them with the asset_url filter or a file from Content > Files.
Check page and product content
Open the HTML view of pages, blog posts and product descriptions and swap any pasted image address for an image uploaded to Shopify.
Check apps and metafields
Look at app blocks and metafields that store image URLs.
Find custom code
Search Project Settings > Custom Code and each page's custom code, plus embed elements, for the bad domain.
Re-upload images
Where an image is set from an external URL, upload it to the Assets panel and select it again.
Publish
Publish to your live domain and check there, not on the webflow.io preview.
Check embeds and custom code
Wix media is hosted by Wix, so look in HTML embeds and Settings > Custom Code for pasted addresses.
Replace the images
Upload the file to the Media Manager and set it on the element again.
Check Code blocks and injection
Search Code blocks and Settings > Advanced > Code Injection for staging or localhost addresses.
Re-add the image
Replace external image links with uploaded images in the page editor.
Search the codebase
Search templates, CSS, JavaScript and config for localhost, 127.0.0.1 and the staging domain.
Use relative paths or an environment variable
Use /images/photo.jpg or a BASE_URL set per environment instead of a hard-coded host.
Rebuild and deploy
Rebuild so generated files contain the new URLs, then purge the CDN.
wp search-replace 'https://staging.example.com' 'https://www.example.com' --all-tables --dry-run
wp search-replace 'https://staging.example.com' 'https://www.example.com' --all-tables
wp search-replace 'http://localhost:8888' 'https://www.example.com' --all-tablesBefore
- <img src="http://localhost:8888/wp-content/uploads/hero.jpg">
- Loads only on the developer's computer
- Visitors see an empty space
After
- <img src="/wp-content/uploads/hero.jpg"> or the live https URL
- Loads for every visitor
- Page looks finished
How to confirm it's fixed
- Reload the page in a private window with cache disabled: all images appear.
- DevTools Network shows no failed image requests and no request to localhost or the staging domain.
- View source search for localhost, 127.0.0.1 and staging returns nothing in src, srcset, data-src, CSS or meta tags.
- The og:image tag uses the live domain.
- Test on a phone using mobile data.
- Check every page in your main funnel, not only the home page.
How to prevent it happening again
Most cases come from pushing staging to live. Make the URL swap a fixed step of every release rather than something you remember.
- Use relative or root-relative image paths where your platform allows.
- Keep the site URL in one setting per environment, never typed into content.
- Run the search and replace as part of every staging-to-live push.
- Add noindex and a password to staging so leaked URLs are easy to spot and do not get indexed.
- After each deploy, open the key funnel pages in a private window and check Network for failures.
- Schedule an automated check of your funnel pages.
Day 1
A page is built on staging with full image URLs.
Day 3
The page is copied to live without a URL replace.
Day 3
Team members still see images because of cache or login.
Day 10
Staging is switched off or password protected and images break for visitors.
Day 11
URLs are replaced and caches cleared.
How FunnelGuard handles this
FunnelGuard detects this today. A robot visitor loads your funnel pages on a schedule as a fresh visitor, with no login or cache. It flags resources that fail to load, such as an image whose request goes to a staging or localhost address, and it checks that expected content is present on the page.
If a failure shows up, FunnelGuard re-checks it from a second region before sending one alert by email, Slack, Teams, WhatsApp, webhook or PagerDuty, with a screenshot and a likely cause. It cannot fix your URLs for you, and it only checks the pages in the journeys you set up. The Free plan covers 1 site and 2 journeys with daily checks and no card, and paid plans have a 3-day free trial.
Questions people ask
Why are my images pointing to localhost?
The page or database was copied from a developer's computer, and the image links were saved as full addresses such as http://localhost:8888/image.jpg. Search your page source and database for localhost and replace it with your live domain.
Why do my images load for me but not for visitors?
You may be logged in to staging, on the same network as the developer, or seeing a cached copy. Visitors have none of that, so a request to a staging or localhost address fails. Test in a private window on mobile data.
How do I replace staging URLs with the live domain in WordPress?
Back up the database, then run a search and replace with WP-CLI (wp search-replace) or a plugin such as Better Search Replace. Run a dry run first, and use a tool that handles serialized data. Then clear all caches.
How do I find every image that uses a staging URL?
Search the page source for localhost, 127.0.0.1 and your staging subdomain, and check the DevTools Network tab for failed image requests. Remember CSS backgrounds, srcset, data-src and the og:image tag.
Can staging image URLs hurt my SEO?
They can. Broken images make pages look poor, and staging addresses that appear in meta tags or sitemaps can be crawled. Keep staging noindexed and password protected, and make sure the live pages only reference live URLs.
Will a redirect from staging to live fix broken images?
Not reliably, and it is not a good approach. Fix the URLs in your content and settings instead. A redirect can also expose or confuse the staging site.
How can I be alerted when an image breaks on my live site?
FunnelGuard loads your funnel pages on a schedule, flags resources that fail to load and sends one alert with a screenshot after a second-region re-check. You can start on the Free plan with no card.
Related issues
- PRF-138Broken image (404) on a funnel pageFix guide
- PRF-139Broken hero or product imageFix guide
- PRF-140Image hotlinked from another site that now blocks itFix guide
- PRF-152Product images missing (placeholder image shown)Fix guide
- PRF-153Open Graph image missing so shared links look brokenFix guide
- PRF-142CSS file 404 so page renders unstyledFix guide