Introduction
localtunnel provides a public HTTPS URL that forwards to a port on your local machine. It is especially useful for testing webhooks, sharing in-progress work with teammates, and running quick demos without deploying to a server.
What localtunnel Does
- Creates an HTTPS tunnel from a public URL to a local port in one command
- Supports custom subdomains so you can get a predictable URL
- Works behind NATs and corporate firewalls without router configuration
- Runs as a CLI tool or can be used programmatically via its Node.js API
- Allows self-hosting the tunnel server for teams that need a private relay
Architecture Overview
localtunnel opens a connection to a remote relay server that listens for incoming HTTPS requests on a generated subdomain. When a request arrives, the server multiplexes it over the existing connection back to the client, which forwards it to the local port. The client maintains a pool of sockets to the relay for concurrent request handling.
Self-Hosting & Configuration
- Install globally with
npm install -g localtunnelor run vianpx - Self-host the server component using
localtunnel-serverfor private relays - Set a custom subdomain with
--subdomain mynamefor a stable URL - Configure the local host with
--local-host 192.168.1.xif not localhost - Supports
--print-requestsflag to log incoming request details
Key Features
- Zero-config tunneling with a single CLI command
- Free public relay at loca.lt with HTTPS included
- Custom subdomains for stable, bookmarkable URLs
- Programmatic API for integration into build scripts and test runners
- Open-source server for self-hosting a private tunnel relay
Comparison with Similar Tools
- ngrok — Feature-rich commercial tunnel with a generous free tier; localtunnel is simpler and fully open-source
- Cloudflare Tunnel — Requires a Cloudflare account; localtunnel needs no sign-up
- Tailscale Funnel — Mesh VPN approach; localtunnel is a lighter single-purpose tool
- bore — Minimal Rust tunnel; localtunnel adds subdomain support and a Node.js API
FAQ
Q: Is the public loca.lt relay free to use? A: Yes. The default relay is free with no sign-up, though it may have rate limits for heavy traffic.
Q: Can I use localtunnel for production traffic? A: It is designed for development and demos. For production, self-host the server or use a dedicated tunnel service.
Q: Does it support TCP or only HTTP? A: localtunnel is HTTP/HTTPS only. For raw TCP tunnels, consider tools like chisel or bore.
Q: How do I get a consistent URL between restarts?
A: Use the --subdomain flag to request the same subdomain each time, for example lt --port 3000 --subdomain myapp.