Zum Inhalt springen

Expose your localhost with 1 command line!

Expose your wepapp with localtunnel

Ever needed to show a local app to a teammate, a webhook, or a QA engineer who “doesn’t run things locally”? Enter localtunnel: the zero-config way to publish your localhost to the internet with a sharable URL. It’s like handing your app a passport and telling it to go see the world—safely, temporarily, and without DNS rituals.

Below is a quick guide with a tiny Node.js + Express “Hello, world!” and how to expose it using the localtunnel library.

What is localtunnel?

localtunnel creates a secure tunnel from a public URL to a port on your machine. You run your app on, say, localhost:3000, and localtunnel gives you a URL like https://curly-pigs-play.loca.lt that forwards traffic to your local server. Perfect for:

  • Testing webhooks from Stripe/GitHub/Twilio
  • Sharing in-progress UI with teammates
  • Quick demos without deploying

Basic Requirements

  • Node.js 18+ (or at least a modern LTS)
  • npm or yarn
  • An open port (we’ll use 3000)
  • Internet connection (the tunnel fairy needs it)

Project Setup

Let’s spin up a tiny Express app and then tunnel it.

1) Initialize a project

mkdir lt-express-demo
cd lt-express-demo
npm init -y
npm install express

2) Create a minimal Express server

Create a file named server.js:

import express from 'express';

const app = express();

app.get('/', (req, res) => {
  res.send('Hello, world! 👋');
});

app.listen(3000, () => {
  console.log('Local server listening on http://localhost:3000');
});

3) Run it locally

node server.js

Verify it works at http://localhost:3000. You should see “Hello, world! 👋”.

Using localtunnel via CLI

You can run your server as usual and in another terminal:

npx localtunnel --port 3000
# or with subdomain
npx localtunnel --port 3000 --subdomain my-snazzy-demo

This prints a public URL. Keep that process running to keep the tunnel open.

Tips, Quirks, and Gotchas

  • Subdomains are “best-effort.” If it’s taken, localtunnel will hand you a random animal-party URL. Embrace the chaos.
  • Tunnels are temporary. When the process dies, the URL goes poof.
  • For webhooks, set the service’s callback URL to your public tunnel URL (e.g., https://purple-mongoose-123.loca.lt/webhooks/stripe).
  • Don’t expose sensitive admin panels without auth. Tunnels are public by design.
  • Firewalls/Corporate networks can be “fun.” If the tunnel can’t connect, check outbound restrictions.

Final Thoughts

localtunnel is a tiny tool that punches way above its weight—perfect for demos, webhooks, and “can you just check this real quick?” moments. Pair it with a simple Express “Hello, world!” and you’ve got the world’s fastest shareable prototype. Now go forth and tunnel like it’s 1999 dial-up, but faster and much less screechy.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert