Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Links pointing to staging or localhost: how to find and fix

CNV-108High impactDetectedBy FunnelGuardPublished Updated
On this page

What this issue is

A staging site is a private copy of your website where you build and test changes. Localhost is the address of a site running on a developer's own computer, such as http://localhost:8080. Neither is meant for the public.

A broken call to action (CTA) is a dead end. The visitor clicked because they wanted to buy or enquire, and they get a connection error, a password prompt or a blank page. Most won't come back.

Where the journey breaks
  1. Ad clickVisitor lands on live page
  2. Click CTALink goes to staging.example.com
  3. Form or checkoutNever reached
  4. ConversionLead or sale not recorded

The visitor reaches the live page, but the main button points to a staging address.

How to check if your site has it

You are looking for any URL that contains your staging host, a development host or localhost. Check the page source, not just what the page shows, because the visible text of a button can look right while its link is wrong.

Find staging and localhost links
  1. Search the page source

    Open the live page, view source (Ctrl+U or Cmd+Option+U) and search for staging, localhost, 127.0.0.1, .local, dev. and your host's temporary domain.

  2. Click every CTA while logged out

    Use a private window. Click the main buttons, menu items, footer links and form submit buttons, and note where each one lands.

  3. Check the hidden places

    Look at the canonical tag, Open Graph tags, sitemap, form action attributes, embedded scripts and image sources, not only visible links.

  4. Test on mobile

    Some themes and builders keep a separate mobile menu or button, which can hold a different link.

Browser console: list links to a staging or local hostjavascript
[...document.querySelectorAll('a[href], form[action]')]
  .map(el => el.href || el.action)
  .filter(u => /localhost|127\.0\.0\.1|staging|\.local|dev\./i.test(u))
  .forEach(u => console.log(u));

How to fix it

The fix is to replace the old host with your live domain everywhere it appears. Where you do it depends on how the site is built.

Replace staging links by platform
  1. Back up first

    Take a full database backup before changing anything.

  2. Run a search and replace

    Use a search-replace plugin or WP-CLI to swap the staging URL for the live URL across the database. It handles serialized data safely, which a plain SQL replace does not.

  3. Check builder and theme settings

    In Settings > General confirm WordPress Address and Site Address are the live domain. Then check Elementor, Divi or theme options for hard-coded button links and regenerate CSS or cache.

  4. Clear caches

    Purge your caching plugin, server cache and CDN so old HTML is not served.

WP-CLI: preview, then run a search and replacebash
wp search-replace 'https://staging.example.com' 'https://www.example.com' --dry-run
wp search-replace 'https://staging.example.com' 'https://www.example.com' --skip-columns=guid
CTA link before and after

Broken

  • Button href is https://staging.example.com/book
  • Visitor sees an error or a password prompt
  • No lead is created

Fixed

  • Button href is https://www.example.com/book
  • Booking page opens normally
  • Lead arrives in inbox and CRM

How to confirm it's fixed

Confirmation checklist
  • Page source no longer contains staging, localhost or dev hostnames
  • The console snippet returns no results on your key landing pages
  • Every main CTA opens the correct live page in a private window
  • Form submit and thank-you page work on desktop and mobile
  • Canonical and Open Graph URLs use the live domain
  • Caches and CDN are purged
  • A test lead reaches your inbox and CRM

How to prevent it happening again

Most cases come from hard-coded absolute URLs and rushed launches. Small habits remove most of the risk.

Prevention habits
  • Use relative links or page pickers instead of typing full URLs
  • Keep the base URL in one setting per environment
  • Add a launch step: search the database and code for the staging host
  • Block search engines and public access on staging with a password
  • Re-test key journeys after every migration, theme update or push from staging
  • Monitor the live journeys on a schedule so a bad link is caught within hours

How FunnelGuard handles this

FunnelGuard detects this today. A robot visitor runs your real customer journey on a schedule, clicks the CTAs and checks each step. If a link leads to a broken page or an error instead of the expected content, the step fails. The check looks for broken links and for expected text that is missing from the page it lands on.

A failure is re-checked from a second region before one alert goes out, so a one-off glitch does not wake you up. The alert (email, Slack, Teams, WhatsApp, webhook or PagerDuty) includes a screenshot and a likely cause. Test traffic is marked with utm_source=funnelguard and fg_test=1. The Free plan covers 1 site and 2 journeys with daily checks and no card.

Example: how a staging link goes unnoticed
  1. Day 0

    Site is copied from staging to live. The Book now button keeps its staging link.

  2. Day 1

    Ads keep sending traffic. Page views look normal.

  3. Day 5

    Enquiries fall. Nobody knows why.

  4. Day 6

    A scheduled journey check fails and an alert arrives with a screenshot.

  5. Day 6

    Link is replaced with the live URL and the journey passes.

Questions people ask

Why do my website links go to a staging site?

The site was copied from staging to live and some links kept the old absolute URL. This often happens with buttons, menu items and page-builder content typed with a full address. A search and replace on the database or code fixes it.

How do I find all staging links on my live website?

View the page source and search for your staging hostname, localhost, 127.0.0.1 and dev. For a whole WordPress site, run a dry-run search-replace to count matches. For custom code, search the whole project, including config and JavaScript files.

Why does my button link to localhost?

A developer added the link while working on a local copy and it was saved into the content or code. Visitors can't open localhost because it points to their own computer. Replace it with your live URL or a relative path.

How do I replace staging URLs with live URLs in WordPress?

Back up the database, then use a search-replace tool or WP-CLI to swap the staging URL for the live one. Do a dry run first, and clear all caches afterwards. Also check page-builder and theme settings for hard-coded links.

Can staging links hurt my SEO?

Yes, they can. If canonical tags or internal links point to staging, search engines may be confused about which page to index. Fix them, and keep staging blocked from public access.

How can I stop staging URLs reaching my live site?

Use relative links, store the base URL in one environment setting and add a pre-launch search for the staging host. Re-test your key journeys after each migration. Scheduled monitoring catches anything that slips through.

Will analytics show that visitors hit a staging link?

Usually not clearly. Analytics records the landing page view on the live site, then the visitor leaves for a different host. You see a drop in conversions rather than an error, which is why a journey check helps.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

How: text_absent / broken links.

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.