# localtunnel — Expose Your Localhost to the World Instantly > localtunnel is a lightweight Node.js tool that assigns a publicly reachable URL to a service running on your local machine. It requires no DNS setup, no firewall changes, and no account sign-up, making it the fastest way to share a local dev server. ## Install Save in your project root: # localtunnel — Expose Your Localhost to the World Instantly ## Quick Use ```bash npx localtunnel --port 3000 # Output: your url is: https://random-slug.loca.lt ``` ## 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 localtunnel` or run via `npx` - Self-host the server component using `localtunnel-server` for private relays - Set a custom subdomain with `--subdomain myname` for a stable URL - Configure the local host with `--local-host 192.168.1.x` if not localhost - Supports `--print-requests` flag 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`. ## Sources - https://github.com/localtunnel/localtunnel - https://theboroer.github.io/localtunnel-www/ --- Source: https://tokrepo.com/en/workflows/a91e036f-4105-11f1-9bc6-00163e2b0d79 Author: AI Open Source