Skip to content

Instantly share code, notes, and snippets.

Forked from mjangda/
Created December 20, 2018 02:15
Show Gist options
  • Save mboynes/c26eb66f1f8e79c4c325dbaf9ef90b72 to your computer and use it in GitHub Desktop.
Save mboynes/c26eb66f1f8e79c4c325dbaf9ef90b72 to your computer and use it in GitHub Desktop.
How to connect ngrok to your local WordPress environment (props @DanReyLop)

How to develop with Jetpack locally with ngrok

To connect Jetpack in your local installation, you'll need a way for servers to reach your server. That can be done in a number of different ways:

  • You can open your router's ports and use your public IP
  • You can use some kind of Dynamic DNS provider.

But these options fall short of ngrok, which is a "localhost tunnel". It basically allows the Internet to hit a local port on your machine without worrying about ports or IPs.

As long as ngrok is running, Jetpack / will be able to communicate with your local site. This will allow remote modules like Site Search and Manage to work.


Install ngrok

To get started:

Create a tunnel

To create a tunnel between ngrok and your local site, you can run the following command at any time:

ngrok http -subdomain=yoursubdomain

Change yoursubdomain for any name that you prefer. Note that the subdomain name isn't reserved, so choose something that's unique and unlikely to be used by someone else.

As long as it keeps running, you'll have an http and https tunnel working.

Update hosts file

Add the following entry to your hosts file:

You may need to flush DNS caches, or restart your browser for this change to take effect.

The hosts file mapping also make it possible for you to use the ngrok URL ( for local development; it will even keep working even without an internet connection.

Update WordPress URLs

Go to your WordPress admin dashboard, Settings > General and change these settings:

  • WordPress Address (URL):
  • Site Address (URL):

Note that you may need to adjust the URL depending on how WordPress is installed. For example, if installed in a subdirectory called wp for local webserver root, your URL should be

Connecting Jetpack

  • Navigate to (you may have to login again).
  • Install, activate and connect Jetpack.

And you're done!

Working with Vagrant / Docker


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment