January 15, 2012

Share Your localhost Online

If you ever wished you could share a website on your localhost with a coworker, remote colleague, or mom, then localtunnel is perfect for you.

I absolutely love this tool. It’s easy to use and straightforward, yet solves a definite need for exposing a local website to the internet. Another great use; mobile testing. Now I can view and test changes on my iPhone without deploying to a live production or development server.

Localtunnel is available as a RubyGem. Make sure Ruby is installed first, then simply follow the localtunnel instructions. If you need to install Ruby on Windows, I recommend RubyInstaller or RailsInstaller.

Once you’ve installed the gem and authenticated your public key, a simple one line command generates the public url which can be shared with anyone online.

// Install the gem:
$ gem install localtunnel

// First time requires authentication with a public key:
$ localtunnel -k ~/.ssh/id_rsa.pub 8080

// All subsequent sessions are this easy:
$ localtunnel 8080

Instructions are available on the localtunnel page, or head over to Github for more details and hardcore forking action. Localtunnel was created by Jeff Lindsay, and is sponsored by Twilio.

Update Jan 5, 2013

Say you’re running WordPress on WampServer… it won’t work, even if localtunnel is running on 8080 or whatnot. It basically works with Rails apps running on Rails server, Unicorn, etc., which is all I needed until recently.

There’s a couple of options If you’re working with a non-Rails app on Windows. I haven’t had the time to try either yet, so please report back if you have any luck.