Sometimes when testing web applications it is needed to have them available from outside (i.e. in public Internet). For example some APIs you use may need to send callbacks.

A solution that helps in such case is creating SSH reverse tunnel to make your local server publicly acessible. However to do this you’ll need publicly acessible box which you can control, with SSH on it and needed ports opened on firewall.

Sometimes you just don’t have one and would like to avoid hassle with purchasing some VPS, etc. In such case localtunnel utility comes in help.

localtunnel is a tool built with specific purpose to temporarily expose local web servers to public Internet. It acts as a client for a public and open source reverse tunneling service. It’s usage is simple:

localtunnel 8080

This command makes local service at port 8080 acessible on the port 80 on the domain it outputs.

Note that of course at first you need to install and configure it.
Installation (for all users) goes like:

sudo gem install localtunnel

Then also on the first run you have to specify your SSH public key to use for authentication, like:

localtunnel -k ~/.ssh/ 8080

If you don’t have SSH keypair, you can generate the keys using ssh-keygen:

ssh-keygen -t rsa

See more info and source code on Github: