Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Image URL points to staging or localhost: how to find and fix it

PRF-141Medium impactDetectedBy FunnelGuardPublished Updated
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.

Where the broken image hurts the funnel
  1. Ad or search clickVisitor reaches the live page
  2. Page loadsHTML and text appear
  3. Image requestPoints to staging or localhost, fails
  4. Visitor trustPage looks broken, visitor leaves
  5. 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

Find staging and localhost image URLs
  1. 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.

  2. 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.

  3. Search the page source

    Press Ctrl+U (Cmd+Option+U on Mac) and search for localhost, 127.0.0.1, staging, dev. and .local. Check src, srcset, data-src and inline background-image styles.

  4. Check the Console

    Look for errors such as net::ERR_CONNECTION_REFUSED (localhost) or mixed content warnings naming the image.

  5. 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.

Quick check from the command linebash
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.

Replace the staging address by platform
  1. Back up the database

    Use your host's backup or a backup plugin before changing anything.

  2. 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.

  3. 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.

  4. Clear caches

    Purge your caching plugin, server cache and CDN.

WordPress: WP-CLI search and replacebash
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-tables
Image URL before and after

Before

  • <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

Confirmation checklist
  • 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.

Release habits
  • 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.
How the problem usually unfolds
  1. Day 1

    A page is built on staging with full image URLs.

  2. Day 3

    The page is copied to live without a URL replace.

  3. Day 3

    Team members still see images because of cache or login.

  4. Day 10

    Staging is switched off or password protected and images break for visitors.

  5. 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.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

How: broken resource / text_absent.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.