Using Localtunnel on Windows

Mustafa Shabib
We Are Mammoth
Published in
2 min readSep 1, 2011

We recently integrated with the awesome Twilio service for a small project we developed. Like many of today’s APIs, Twilio offers a number of webhooks that alert you to changes on the Twilio side. This simple but great concept really opens up a lot of possibilities for API users everywhere, and I’m glad to see it spreading. Unfortunately, webhooks by their very nature require that you have a publicly accessible URI for the service to callback to, which makes developing your webhook handler a little bit difficult when you’re working locally. Enter localtunnel, a nifty little tool that makes localhost visible to the rest of the world and lets you build and debug your webhooks on your development environment without having to worry about publishing your changes every few minutes to a public site.

Unfortunately, if you’re developing on Windows, localtunnel won’t work quite as easily out of the box as it would for Mac and *nix users.

Here at WAM, we mainly develop on Microsoft’s .NET platform, which acted as a barrier to our ability to use localtunnel. Since the tool was attractive enough to warrant spending a little time setting it up on my Windows environment, however, I dug in my heels and figured out the general steps needed to get it working.

Rather than go through the number of misguided steps I followed due to my own unfamiliarity with the tools localhost relies on, I’ll cut to the chase and explain what I eventually set up to get everything working together.

  1. First, install Cygwin. During installation, make sure you opt to install dev tools — you’ll definitely need at least Make, gcc, SSH and Ruby.
  2. Download and unzip RubyGems into a folder that you can access under Cygwin.
  3. Install RubyGems by changing to that temporary directory on your Cygwin bash prompt and running:
  • ruby setup.rb
  1. Install localtunnel by running:
  • gem install localtunnel
  1. Generate a public/private key by running.
  • ssh-keygen
  1. When it prompts you for a file to save, enter nothing and press enter. It will put the file into your home folder. ‘~/.ssh’ and the path to the file is ‘~/.ssh/id_rsa.pub’ by default.
  2. Make note of where your public key is saved.
  3. Run localtunnel for the first time by running
  • localtunnel -k {Path_To_Your_Public_Key} {PORT_NUMBER}
  1. For example
  • localtunnel -k ~/..sh/id_rsa.pub 8080
  1. This will upload your public key to localtunnel and respond with something like
  • This localtunnel service is brought to you by Twilio.
  • Port 8080 is now publicly accessible from
  • http://3ivy.localtunnel.com ...
  1. From then on, you can just run
  • localtunnel 8080
  1. And get a temporary public URL for your local app.

One thing to note is that I had to use a port like 8080 to get it to work — something like 49581 wasn’t working and rather than fiddle with it anymore, I just set up vs.net to always build my local project to port 8080.

As always, your mileage may vary and this comes with the standard warning that this worked for me, but may not for you.

Good luck!

--

--

Mustafa Shabib
We Are Mammoth
0 Followers
Writer for

Techy @wammoth Husband and fan of @nonniemen Buddy #1 of @ziggythedogstardust Friend to #all