Do you feel too constrained by localhost? Need a quickly-deployed remote demo? Localtunnel may be the tool for you.
Localtunnel is a simple tool that provides you a publicly-accessible URL that reroutes every request to your locally-running process (hence the library’s questionable tagline “Expose yourself to the world”).
A Few Uses for Localtunnel
I’ve read of people who use Localtunnel to test out webhook APIs that require registering a URL. Another interesting use case is quickly exposing a locally-running demo to remote clients. This way, you can iterate on the source directly as a client views what appears to be a fully-deployed demo.
I found Localtunnel while searching for a way to point a mobile application’s debug builds at a local server. We had a setup where simulated phones could use localhost, but debug and production installs pointed to our staging servers. To allow for quicker iterations and more control, we were able to replace our staging server’s URL with a Localtunnel proxy.
So how do you use it? As I’ve alluded to in the title, it really is just two commands. Initial install through npm:
$ npm install -g localtunnel
And then running it:
$ lt -p <PORT>
<PORT> with the port where your local process is running, and Localtunnel should emit a URL of the form
https://something.localtunnel.me. You can go one step further and request a custom subdomain with:
$ lt -p <PORT> -s <WORD>
This command will give you
https://<WORD>.localtunnel.me, as long as that subdomain is available. This is a great option if you need to hardcode a server’s URL into your source or if you want a readable demo URL to pass to a client.
Benefits of Localtunnel
I was drawn to Localtunnel because of its simplicity — two commands, no DNS or Firewall settings, no fuss. You just install and go.
I also appreciate that it’s an open source library. In fact, Localtunnel’s server component is also open-sourced, which means you can spin your own, giving you full control without any external access. I haven’t done this yet, but I could imagine scenarios in the future where it may be worth the configuration time.
If you search for similar tools — there are a handful of options — the contender you’ll likely find first is ngrok. Ngrok has all of the same features as Localtunnel (plus more), but it does require creating an account. Ngrok even has paid services that offer even more features.
The one major benefit I’ve seen from ngrok seems to be stability. In the month that I have been using Localtunnel, it has been unavailable for me twice: once for unknown reasons, and once for an expired SSL certificate. Both cases were resolved within several days.
Localtunnel and ngrok seem to be the two leading tools in this space. Relatively simple use cases should probably go with the simple Localtunnel option (as I did). But if you are looking to do more with your proxy, you may want to do some research into the feature sets of ngrok.
Finally, before deciding to try out Localtunnel or any similar tool, make sure to consider the security implications of doing so. I had two major concerns when I first found Localtunnel:
- You are entrusting an anonymous third-party with every request and response on your server.
- Your entire service is exposed to the outside world.
I came to the conclusion that the first concern is a non-issue as long as you are using proper encryption. For the second point, make sure your service doesn’t reveal any sensitive data or secrets.
Do you know if this is still working? When I run `lt –port 9000` it never returns with a URL. From their github repo there is a URL, https://localtunnel.me, that also never loads a page. Am I missing something
Found this in the Issues of the repo: https://github.com/localtunnel/localtunnel/issues/343
Unfortunately, the service has been down for quite some time and it doesn’t seem to be actively maintained. I’ve used ngrok in the meantime and been pretty satisfied with it. This Github issue seems to imply that there is a flag to use a non-SSL alternative in Localtunnel if that fits your needs. There’s also self hosted options documented on the Github, but I’ve never needed the service bad enough to warrant the extra effort.
Comments are closed.