Published on

Expose your localhost to the world (ngrok free alternative)

2 min read

Authors

ngrok used to be my (and many) go to tools to expose a local web server to the internet, because it was simple.

With one line of command,

ngrok http 3000

suddenly your local web server can be opened from anywhere. it was as easy as that.

this is useful for several things:

  • Sharing your work to your friend/co-worker
  • Testing a webhook
  • Setting up a callback url with HTTPS
  • Spin up a simple endpoint that anyone can use temporarily

Right now, when you run that same command, this is the output on the command line:

but when you open the generated link in the browser:

Creating an account and generating api key is now mandatory.

Recently I stumbled upon localtunnel, it offers the same feature (exposing localhost) and more!

To use it, you can install them via npm (node is required)

# install it globally
npm install -g localtunnel

# the executable is `lt`
lt --port 3000

After a friendly reminder

You can access your localhost online, back to easy time!

Wait, there's more! My favorite one is the ability to set up a preferred subdomain for the url.

lt --port 3000 --subdomain sakis

Your public url is now: https://sakis.loca.lt, no more gibberish string at the start of your url.

Even if you don't want to install localtunnel globally, you can just run it via npx

npx localtunnel --port 3000 --subdomain sakis

Easy.

That's all for my quick and simple post about localtunnel, if you think this is cool, please share it with others!

Thank you.