How to enable Jetpack on localhost

It happens very often to configure a WordPress installation on a local web server. However, not every plugin we’re going to install may work, since we are in a context outside the public DNS and therefore most of the services that require a connection and exchange of information with the outside will be limited or blocked.

Automattic Jetpack is one of these, but there exists a way we can use it on localhost; at least, the very basic functions.

To be able to use some of the Jetpack’s features on a localhost enviroment you must enable its DEBUG mode by adding the following code to your wp-config.php in WordPress:

const JETPACK_DEV_DEBUG = true;

Basically, Jetpack’s DEBUG mode is automatically activated whenever the URL of your WordPress installation contains a dot, eg: http://mywebsite.local but most of the times you’ll end up with the classic
http://localhost/my-installation: this is the case when you have to turn the DEBUG mode on as seen before.

Automattic Jetpack has also a special WordPress filter you can use to enable/disable the DEBUG mode and is quite useful when you’re developing a theme or plugin.

add_filter('jetpack_development_mode', '__return_true');

Keep in mind that what shown here is a simple method that enables all those service which doesn’t need an outgoing connection to wordpress.com. However, it is a good solution to enable most of the Jetpack’s features on a localhost enviroment, as also described here.