Flywheel Local Site Redirects to Live Site

I recently had a harddrive crash and we replaced it, forcing me to do a fresh install of local. Before the crash, my sites automatically directed to the local version without doing any wp-cli, which is the main reason why I did it this way since we’re not able to push from local yet.

Unfortunately, now my local sites are redirecting to the live site which makes local dev work impossible. Is there a way to fix this?

I’m on a Mac, High Sierra… here’s the log file.

local-by-flywheel.log (635.8 KB)

Hi Jennifer,

Please try the following:

  1. Right-click on the site in Local
  2. Go to ‘Open Site SSH’
  3. Enter wp search-replace '//olddomain.com' '//newdomain.com' (olddomain.com being your live domain and newdomain.com being your Local site domain)
  4. Press Enter
  5. Check your Local site

If the site is still redirecting, try testing it in an incognito/private window to ensure that the redirect isn’t cached in your browser.

That’s exactly what I’m saying. Prior to my crash I DID NOT have to do this, so I want to know why I suddenly have to and if there’s a way to fix it so in the future I don’t have to run search-replace everytime I pull something to local.

Sorry for the hasty reply! I just wanted to make sure you could continue to work on your Local site ASAP.

What version of Local are you running? Also, is there any way you can send me (private message or e-mail) one of the backups you’ve imported that’s still redirecting to the live site?

@Jhynnifer,

I was able to reproduce the issue you were running into with the Flywheel site you specified. There is a plugin (Leadpages) that is throwing a fatal PHP error when WP-CLI is used.

Here’s the specific error for posterity:

Fatal error: Uncaught Error: Call to a member function checkAndCreateApiKey() on null in /app/public/wp-content/plugins/leadpages/leadpages.php:166
Stack trace:
#0 /app/public/wp-includes/class-wp-hook.php(286): isApiKeyCreated('')
#1 /app/public/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)
#2 /app/public/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
#3 /app/public/wp-settings.php(471): do_action('wp_loaded')
#4 phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(1105): require('/app/public/wp-...')
#5 phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(1032): WP_CLI\Runner->load_wordpress()
#6 phar:///usr/local/bin/wp/php/WP_CLI/Bootstrap/LaunchRunner.php(23): WP_CLI\Runner->start()
#7 phar:///usr/local/bin/wp/php/bootstrap.php(75): WP_CLI\Bootstrap\LaunchRunner->process(Object(WP_CLI\Bootstrap\BootstrapState))
#8 phar:///usr/local/bin/wp/php/wp-cli.php(23): WP_CLI\bootstrap()
#9 phar:///usr/local/bin/wp/php/boot-phar.php(8): include('phar:///usr/loc...')
#10 /usr/local/bin/wp(4): include('phar: in /app/public/wp-content/plugins/leadpages/leadpages.php on line 166

This explains the timing of the behavior. :slight_smile:


To fix the issue right now, you can:

  1. Update Leadpages and/or contact Leadpages support to resolve the PHP error

or:

  1. Go through the WP-CLI steps in my previous reply but change step #3 to wp --skip-plugins search-replace '//olddomain.com' '//newdomain.com'

I’ll make sure that --skip-plugins and --skip-themes are used in future versions of Local so PHP errors like this don’t interrupt the domain replacement process.

Thanks for your patience!

While I was waiting, I deleted out that plugin and did the wp search-replace you suggested and in both normal and incognito browsers it’s still redirecting. ><

@Jhynnifer,

Try the following:

  1. Go to the site in Local
  2. Go to Database » Adminer
  3. Go to the wp_XXXXX_options table (click the select button beside it in the sidebar)
  4. Make sure both the siteurl and home options are set to the appropriate local domain. If not, use the edit links to change them.

Once you’ve done that, go ahead and try visiting the Local site again. Another browser may be needed to verify that it’s not redirecting anymore.


Another option you can try is deleting the Leadpages plugin on the live site and then pulling the site to a new Local site with a different local domain.

IT WORKED! OH LAWDY HURRAY HURRAH.

Clay, you are the best. Thank you!

images

1 Like

Haha, glad to hear! Thanks for hanging in there :slight_smile: