Convert Figma logo to code with AI

localtunnel logolocaltunnel

expose yourself

20,883
1,465
20,883
162

Top Related Projects

96,822

A fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.

Minimal, self-hosted, 0-config alternative to ngrok. Caddy+OpenSSH+50 lines of Python.

24,356

Unified ingress for developers

4,832

Applicative Protocol Multiplexer (e.g. share SSH and HTTPS on the same port)

Fast and secure tunnels over HTTP/2

9,969

🕳 bore is a simple CLI tool for making tunnels to localhost

Quick Overview

Localtunnel is an open-source tool that allows you to expose your localhost server to the internet. It creates a secure tunnel from a public URL to your local machine, making it easy to share your work or test webhooks without deploying your code.

Pros

  • Easy to use with a simple command-line interface
  • Provides a public URL for your local server without any configuration
  • Supports custom subdomains for easier sharing and remembering
  • Works behind firewalls and NATs

Cons

  • Relies on third-party servers, which may have occasional downtime
  • Free service may have limitations on bandwidth and concurrent connections
  • Public URLs are temporary and change each time you restart the tunnel
  • May not be suitable for production environments or handling sensitive data

Code Examples

  1. Basic usage to expose a local server:
const localtunnel = require('localtunnel');

(async () => {
  const tunnel = await localtunnel({ port: 3000 });
  console.log('Tunnel URL:', tunnel.url);
})();
  1. Using a custom subdomain:
const localtunnel = require('localtunnel');

(async () => {
  const tunnel = await localtunnel({ port: 3000, subdomain: 'myapp' });
  console.log('Tunnel URL:', tunnel.url);
})();
  1. Handling tunnel events:
const localtunnel = require('localtunnel');

(async () => {
  const tunnel = await localtunnel({ port: 3000 });
  
  tunnel.on('close', () => {
    console.log('Tunnel closed');
  });

  tunnel.on('error', (err) => {
    console.error('Tunnel error:', err);
  });
})();

Getting Started

To use Localtunnel in your project, follow these steps:

  1. Install Localtunnel:

    npm install localtunnel
    
  2. Create a new JavaScript file (e.g., tunnel.js) with the following content:

    const localtunnel = require('localtunnel');
    
    (async () => {
      const tunnel = await localtunnel({ port: 3000 });
      console.log('Tunnel URL:', tunnel.url);
    
      tunnel.on('close', () => {
        console.log('Tunnel closed');
      });
    })();
    
  3. Run your local server on port 3000.

  4. Start the tunnel by running:

    node tunnel.js
    
  5. Your local server is now accessible via the provided tunnel URL.

Competitor Comparisons

96,822

A fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.

Pros of frp

  • More feature-rich, supporting multiple protocols (TCP, UDP, HTTP, HTTPS, STCP)
  • Offers better security features, including TLS encryption and authentication
  • Provides a web-based dashboard for easier management and monitoring

Cons of frp

  • More complex setup and configuration compared to localtunnel
  • Requires both client and server components, increasing deployment complexity
  • Less suitable for quick, temporary tunneling needs

Code Comparison

frp client configuration:

[common]
server_addr = x.x.x.x
server_port = 7000

[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6000

localtunnel usage:

lt --port 8000

Summary

frp is a more powerful and versatile tool for creating reverse proxies and tunnels, offering advanced features and better security. However, it comes with increased complexity in setup and deployment. localtunnel, on the other hand, is simpler to use and better suited for quick, temporary tunneling needs, but lacks the advanced features and security options of frp. The choice between the two depends on the specific requirements of the project and the user's technical expertise.

Minimal, self-hosted, 0-config alternative to ngrok. Caddy+OpenSSH+50 lines of Python.

Pros of SirTunnel

  • Lightweight and simple implementation
  • Focuses on security with built-in HTTPS support
  • Allows custom domain usage without additional configuration

Cons of SirTunnel

  • Less mature project with fewer contributors
  • Limited documentation and community support
  • Fewer features compared to Localtunnel

Code Comparison

SirTunnel:

const tunnel = new SirTunnel({
  targetPort: 3000,
  subdomain: 'myapp'
});
await tunnel.start();

Localtunnel:

const localtunnel = require('localtunnel');
const tunnel = await localtunnel({ port: 3000 });
console.log(tunnel.url);

Both projects aim to provide tunneling services for local development, but they differ in implementation and features. SirTunnel emphasizes simplicity and security, while Localtunnel offers a more established ecosystem with broader functionality.

SirTunnel's built-in HTTPS support and custom domain usage without additional configuration make it attractive for developers prioritizing security and ease of use. However, its limited documentation and smaller community may pose challenges for some users.

Localtunnel, being a more mature project, offers extensive documentation, wider community support, and additional features. It's generally more flexible but may require extra steps for certain security configurations.

The code comparison shows that both projects have straightforward APIs, with SirTunnel offering a slightly more object-oriented approach compared to Localtunnel's function-based implementation.

24,356

Unified ingress for developers

Pros of ngrok

  • More feature-rich, offering advanced functionalities like request inspection and replay
  • Better documentation and user interface
  • Supports TCP tunneling in addition to HTTP/HTTPS

Cons of ngrok

  • Free tier has limitations on number of tunnels and connections
  • Closed-source, which may be a concern for some users
  • Requires account creation for usage

Code Comparison

ngrok:

ngrok http 8080

localtunnel:

lt --port 8080

Both tools offer simple command-line usage for creating tunnels. ngrok provides more options for customization, while localtunnel focuses on simplicity.

Key Differences

  • ngrok offers a web interface for monitoring and inspecting traffic
  • localtunnel is open-source, allowing for community contributions and modifications
  • ngrok provides more detailed analytics and logging capabilities
  • localtunnel has a simpler setup process, not requiring account creation

Use Cases

ngrok is better suited for:

  • Development environments requiring advanced features
  • Projects needing detailed traffic analysis
  • Applications using TCP protocols

localtunnel is ideal for:

  • Quick and simple tunnel setup
  • Open-source projects
  • Basic web development needs

Both tools effectively expose local servers to the internet, but ngrok offers more features at the cost of some limitations in its free tier, while localtunnel prioritizes simplicity and openness.

4,832

Applicative Protocol Multiplexer (e.g. share SSH and HTTPS on the same port)

Pros of sslh

  • Supports multiple protocols (HTTP, SSL, SSH, OpenVPN, etc.) on a single port
  • Provides protocol multiplexing for efficient use of network resources
  • Offers more advanced configuration options for fine-tuned control

Cons of sslh

  • More complex setup and configuration compared to Localtunnel
  • Primarily focused on server-side implementation, not as user-friendly for client-side usage
  • May require more technical knowledge to implement and maintain

Code Comparison

sslh configuration example:

listen:
(
    { host: "0.0.0.0"; port: "443"; }
);
protocols:
(
    { name: "ssh"; service: "ssh"; host: "localhost"; port: "22"; },
    { name: "http"; host: "localhost"; port: "80"; },
    { name: "ssl"; host: "localhost"; port: "443"; }
);

Localtunnel usage example:

const localtunnel = require('localtunnel');

(async () => {
  const tunnel = await localtunnel({ port: 3000 });
  console.log(tunnel.url);
})();

While sslh focuses on server-side protocol multiplexing, Localtunnel provides a simpler solution for exposing local servers to the internet. sslh offers more advanced features and flexibility, but Localtunnel is easier to use for quick tunneling needs.

Fast and secure tunnels over HTTP/2

Pros of go-http-tunnel

  • Written in Go, offering better performance and lower resource usage
  • Supports multiple tunnels with a single client
  • Provides more advanced features like custom headers and TLS configuration

Cons of go-http-tunnel

  • Less user-friendly for beginners compared to localtunnel
  • Smaller community and fewer resources available
  • Requires more setup and configuration

Code Comparison

localtunnel:

const localtunnel = require('localtunnel');

(async () => {
  const tunnel = await localtunnel({ port: 3000 });
  console.log(tunnel.url);
})();

go-http-tunnel:

package main

import "github.com/mmatczuk/go-http-tunnel"

func main() {
    tunnelConfig := tunnel.ClientConfig{
        ServerAddr: "example.com:5223",
        Tunnels: map[string]*tunnel.Tunnel{
            "www": {
                Proto: "http",
                Addr:  "localhost:8080",
            },
        },
    }
    client, _ := tunnel.NewClient(&tunnelConfig)
    client.Start()
}

The code comparison shows that go-http-tunnel requires more setup and configuration, but offers more flexibility in tunnel creation. localtunnel, on the other hand, provides a simpler API for quick setup and usage.

9,969

🕳 bore is a simple CLI tool for making tunnels to localhost

Pros of Bore

  • Written in Rust, offering better performance and memory safety
  • Supports both TCP and UDP protocols
  • Allows custom subdomain selection

Cons of Bore

  • Less established and potentially less stable than Localtunnel
  • Smaller community and fewer resources available
  • May require more setup and configuration

Code Comparison

Localtunnel (JavaScript):

const localtunnel = require('localtunnel');

(async () => {
  const tunnel = await localtunnel({ port: 3000 });
  console.log(tunnel.url);
})();

Bore (Rust):

use bore_cli::{client, client::BoreholeBuilder};

let borehole = BoreholeBuilder::new("example.com", 8080)
    .local_port(3000)
    .build()?;
println!("Tunnel URL: {}", borehole.remote_addr());

Both Localtunnel and Bore are tools for exposing local servers to the internet. Localtunnel is a more established project with a larger user base and simpler setup, making it ideal for quick prototyping and testing. Bore, being newer and written in Rust, offers potential performance benefits and additional features like UDP support, but may require more configuration and has a smaller community. The choice between the two depends on specific project requirements and user preferences.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

localtunnel

localtunnel exposes your localhost to the world for easy testing and sharing! No need to mess with DNS or deploy just to have others test out your changes.

Great for working with browser testing tools like browserling or external api callback services like twilio which require a public url for callbacks.

Quickstart

npx localtunnel --port 8000

Installation

Globally

npm install -g localtunnel

As a dependency in your project

yarn add localtunnel

CLI usage

When localtunnel is installed globally, just use the lt command to start the tunnel.

lt --port 8000

Thats it! It will connect to the tunnel server, setup the tunnel, and tell you what url to use for your testing. This url will remain active for the duration of your session; so feel free to share it with others for happy fun time!

You can restart your local server all you want, lt is smart enough to detect this and reconnect once it is back.

Arguments

Below are some common arguments. See lt --help for additional arguments

  • --subdomain request a named subdomain on the localtunnel server (default is random characters)
  • --local-host proxy to a hostname other than localhost

You may also specify arguments via env variables. E.x.

PORT=3000 lt

API

The localtunnel client is also usable through an API (for test integration, automation, etc)

localtunnel(port [,options][,callback])

Creates a new localtunnel to the specified local port. Will return a Promise that resolves once you have been assigned a public localtunnel url. options can be used to request a specific subdomain. A callback function can be passed, in which case it won't return a Promise. This exists for backwards compatibility with the old Node-style callback API. You may also pass a single options object with port as a property.

const localtunnel = require('localtunnel');

(async () => {
  const tunnel = await localtunnel({ port: 3000 });

  // the assigned public url for your tunnel
  // i.e. https://abcdefgjhij.localtunnel.me
  tunnel.url;

  tunnel.on('close', () => {
    // tunnels are closed
  });
})();

options

  • port (number) [required] The local port number to expose through localtunnel.
  • subdomain (string) Request a specific subdomain on the proxy server. Note You may not actually receive this name depending on availability.
  • host (string) URL for the upstream proxy server. Defaults to https://localtunnel.me.
  • local_host (string) Proxy to this hostname instead of localhost. This will also cause the Host header to be re-written to this value in proxied requests.
  • local_https (boolean) Enable tunneling to local HTTPS server.
  • local_cert (string) Path to certificate PEM file for local HTTPS server.
  • local_key (string) Path to certificate key file for local HTTPS server.
  • local_ca (string) Path to certificate authority file for self-signed certificates.
  • allow_invalid_cert (boolean) Disable certificate checks for your local HTTPS server (ignore cert/key/ca options).

Refer to tls.createSecureContext for details on the certificate options.

Tunnel

The tunnel instance returned to your callback emits the following events

eventargsdescription
requestinfofires when a request is processed by the tunnel, contains method and path fields
errorerrfires when an error happens on the tunnel
closefires when the tunnel has closed

The tunnel instance has the following methods

methodargsdescription
closeclose the tunnel

other clients

Clients in other languages

go gotunnelme

go go-localtunnel

C#/.NET localtunnel-client

Rust rlt

server

See localtunnel/server for details on the server that powers localtunnel.

License

MIT

NPM DownloadsLast 30 Days