To enable local development on the latest version of Jetpack:
- Install or upgrade to Jetpack’s latest version if you have not done so already
- Deactivate the plugin if you already have it installed and activated
define ('JETPACK_DEV_DEBUG', true);to your wp-config.php file
- Refresh the admin panel and you should now be good to go for local development. Simply activate the modules you want to implement
This is much easier than the instructions I have outlined below. Thanks be to the Jetpack DEVs for addressing this much needed issue.
Only proceed if using an older version of Jetpack
Jetpack is a quickly becoming one of my favorite WordPress plugins. It includes a ton of excellent features including built-in analytics (that don’t suck), social media integration, backup options, forms and subscriptions (plus much more). My one big complaint is that it’s not so simple to use when developing on localhost.
If you have tried already to enable Jetpack on your localhost you most likely saw the following message: “Your website needs to be publicly accessible to use Jetpack: site_inaccessible” followed by “Error Details: The Jetpack server was unable to communicate with your site” yadda yadda…
Here I’ll show you how to ‘trick’ Jetpack into thinking it’s connected to WordPress.com so you can go about development locally as normal.
Before We Start: Online and Offline Environments
To begin you will need an online WordPress environment to install Jetpack on and have access to the database either through PHPMyAdmin or another interface. For this article, we will use PHPMyAdmin to export the necessary data.
You should already have a local WordPress site setup since you are searching for this specific article BUT if don’t be sure to set that up prior to proceeding. Are you all set? Great, let’s get started with the process. It’s really not that bad…
The Solution: Jetpack for Localhost
The first step is to Install and Activate Jetpack in both your online and local WordPress environments. Once you activate Jetpack you should see the following screen:
In your online environment click the “Connect to WordPress.com” button and agree to connect your website to WordPress.com:
If all went well with the process you are now connected to WordPress.com in your online environment:
How to Connect Jetpack on Localhost
Now that we have our online environment’s Jetpack connected and functional we’re going to use some of that data for our local environment. Open up PHPMyAdmin and select the database that your online environment is connected to. Click on the “SQL” tab and run the following query:
SELECT * FROM `wp_options` WHERE `option_name` = 'jetpack_options';
Here’s what it should look like:
You should have 1 result displaying some data in serialized format:
Now, login to your localhost PHPMyAdmin and run this same SQL query on the database connected to your local WordPress install. You should also see one result with similar data as displayed in the image above.
Here’s the ‘trick’ to the whole process: We are going to copy-and-paste the data within the ‘option_value’ column from your online environment to your local environment. To do that we will click “Edit” in your online SQL search results and copy the data within the value field:
Next change tabs/windows to the SQL results of your local database query and click “Edit” as we did before and paste the data:
Don’t forget to save by clicking “Go”.
Test Your Localhost Jetpack Connection
If everything went through properly you will now be able to go to WP-Admin -> Jetpack and see the “Connected to WordPress.com” message and activate various features as expected:
I hope this helps some other developers and WordPressers out there! If you are having any issues please use the comments below!