Code Monkey home page Code Monkey logo

localtunnel's Introduction

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

event args description
request info fires when a request is processed by the tunnel, contains method and path fields
error err fires when an error happens on the tunnel
close fires when the tunnel has closed

The tunnel instance has the following methods

method args description
close close 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

localtunnel's People

Contributors

adammck avatar angelobreuer avatar aronwoost avatar basaba avatar circlecode avatar cktang88 avatar dan-kez avatar davej avatar defunctzombie avatar dscape avatar eagleeye avatar fredipevcin avatar gaards avatar ghengeveld avatar holic avatar jimmiebtlr avatar jonasfj avatar joshuaxls avatar kaichaosun avatar kesla avatar linusu avatar lykathia avatar missingcharacter avatar sebdeckers avatar sigvef avatar tootallnate avatar tpaszun avatar vrunoa avatar zeevl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

localtunnel's Issues

local not defined on line 62

Getting this error:

/usr/local/lib/node_modules/localtunnel/client.js:62
                    local.emit('error', err);
                    ^
ReferenceError: local is not defined
    at Socket.remote_attempts (/usr/local/lib/node_modules/localtunnel/client.js:62:21)
    at Socket.g (events.js:192:14)
    at Socket.EventEmitter.emit (events.js:126:20)
    at Socket._destroy.self.errorEmitted (net.js:329:14)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)

Seems that local is not defined:

            remote.once('error', function(err) {
                if (err.code !== 'ECONNREFUSED') {
                    local.emit('error', err);
                }

                // retrying connection to local server
                setTimeout(conn, 1000);
            });

I'm also having the problem with static content on Express not loading.

Connection Resets are crashing the tunnel

I'm getting the following error when a user resets their connection

stream.js:94
      throw er; // Unhandled stream error in pipe.
            ^
Error: read ECONNRESET
    at errnoException (net.js:904:11)
    at TCP.onread (net.js:558:19)

No message after lt run after node manually installed

Hello.

According to: #9

I do not know why, bud I see node wasn't installed. So I installed it additionaly:
sudo apt-get install node

Now I have no error messages when I try to run lt --port 80.
I have no any feedback:

root@raspberrypi:/home/pi/# lt --port 80
root@raspberrypi:/home/pi/# lt --port 80
root@raspberrypi:/home/pi/# lt --port 80
root@raspberrypi:/home/pi/# lt --port 80
root@raspberrypi:/home/pi/#

Some advices ?

Broken HeaderHostTransformer (Property '_transform' of object [object Object] is not a function)

Because of this

self._transform = undefined;

i get an error:

_stream_transform.js:179
    this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
         ^
TypeError: Property '_transform' of object [object Object] is not a function
    at Transform._read (_stream_transform.js:179:10)
    at Transform._write (_stream_transform.js:167:12)
    at doWrite (_stream_writable.js:221:10)
    at writeOrBuffer (_stream_writable.js:211:5)
    at Writable.write (_stream_writable.js:180:11)
    at Socket.ondata (stream.js:51:26)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Socket.<anonymous> (_stream_readable.js:746:14)
    at Socket.EventEmitter.emit (events.js:92:17)
    at emitReadable_ (_stream_readable.js:408:10)

Possible solution is to remove self._transform = undefined;

Static assets not loading.

When I try to view my [email protected] app through local tunnel, the page loads but most (if not all) static assets 404. If I pick one of the failing assets and load it directly, it loads fine.

The assets also load fine via localhost:3000 or proxied via nginx.

Can you offer any advice where I should start debugging this?

Huge props for making this local tunnel node client. It is the PERFECT way to implement local tunnel into a nodejs app. Just need to solve this asset issue.

Keep getting a [trace] when running server

I run ./bin/server --port 8023 and then there is this message that keeps appearing:

[trace] no client found for id: doms

It repeats over and over every second. What does it mean?

localltunnel.me appears to be down

Any one knows of any other domains that have localtunnel-server hosted?
Any node.js hostings that will work for installing it there on my own (registering my own domain) (Joyent? Nodester?) ?

Thanks!

POST not getting forwarded

Is there a difference between the code that localtunnel.me is running compared to what's in master?

For some reason, localtunnel.me forwards my POSTs while a local install isn't (but it's not consistent). What's your max_tcp_sockets set to on localtunnel.me?

TypeError: Object #<Socket> has no method 'unpipe'

Hi there,

I keep getting this after a payload is delivered:

/usr/local/share/npm/lib/node_modules/localtunnel/client.js:75
            local.unpipe();
                  ^
TypeError: Object #<Socket> has no method 'unpipe'
    at Socket.remote_close (/usr/local/share/npm/lib/node_modules/localtunnel/client.js:75:19)
    at Socket.g (events.js:192:14)
    at Socket.EventEmitter.emit (events.js:126:20)
    at Socket._destroy.destroyed (net.js:358:10)
    at process.startup.processNextTick.process._tickCallback (node.js:245:9)

any idea?

tunnels with subdomain specified start timing out at some point

Hi there. I've just encountered an issue. I've been using the same subdomain for a few weeks now, on an off. Over the last two days I've started to get timeouts connecting to that subdomain. Here is my tunnel command:

lt --port 80 --subdomain localsso --local_host privia.dev

If I kill the tunnel and restart it, it sometimes begins working again, and if I specify no subdomain, or another subdomain things work as expected. Also things start working again after the tunnel has been down overnight (I don't have more specifics on the timeline yet).

The timeout error I'm seeing is from nginx, not from my server.

Enable connecting to localtunnel proxy through a corporate proxy

(Sorry if this is already possible, and documented somewhere: I couldn't find it.)

I'm trying to connect to localtunnel.me from a PC that's behind a corporate proxy. I'd like to be able to configure lt to go through our internal corporate proxy in order to reach the localtunnel.me server.

As things stand, when I type lt --port 8000, I get

tunnel server offline: connect ECONNREFUSED, retry 1s

over and over and over...

rbuf_fill execution expired

I'm getting this error, every time i try to execute localtunnel

/usr/lib/ruby/1.8/timeout.rb:64:in `rbuf_fill': execution expired (Timeout::Error)
    from /usr/lib/ruby/1.8/net/protocol.rb:134:in `rbuf_fill'
    from /usr/lib/ruby/1.8/net/protocol.rb:116:in `readuntil'
    from /usr/lib/ruby/1.8/net/protocol.rb:126:in `readline'
    from /usr/lib/ruby/1.8/net/http.rb:2028:in `read_status_line'
    from /usr/lib/ruby/1.8/net/http.rb:2017:in `read_new'
    from /usr/lib/ruby/1.8/net/http.rb:1051:in `request'
    from /usr/lib/ruby/1.8/net/http.rb:948:in `request_get'
    from /usr/lib/ruby/1.8/net/http.rb:380:in `get_response'
    from /usr/lib/ruby/1.8/net/http.rb:543:in `start'
    from /usr/lib/ruby/1.8/net/http.rb:379:in `get_response'
    from /usr/lib/ruby/1.8/net/http.rb:356:in `get'
    from /var/lib/gems/1.8/gems/localtunnel-0.3/lib/localtunnel/tunnel.rb:27:in `register_tunnel'
    from /var/lib/gems/1.8/gems/localtunnel-0.3/bin/localtunnel:46
    from /usr/local/bin/localtunnel:19:in `load'
    from /usr/local/bin/localtunnel:19

Any ideas?

Cannot read property 'prototype' of undefined

Trying to run on Mac

$ lt --port 8000

util.js:538
  ctor.prototype = Object.create(superCtor.prototype, {
                                          ^
TypeError: Cannot read property 'prototype' of undefined
    at Object.exports.inherits (util.js:538:43)
    at Object.<anonymous> (/usr/local/Cellar/node/0.8.20/lib/node_modules/localtunnel/client.js:25:6)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at Object.<anonymous> (/usr/local/Cellar/node/0.8.20/lib/node_modules/localtunnel/bin/client:2:17)
    at Module._compile (module.js:449:26)

Thanks!

Restrict to path under local-host and port?

Often times I'll throw HTML files into a local Nginx server running on 8080 with autoindex turned on to let me browse the file tree. It would be great if I could fire up a localtunnel while restricting requests to a certain path under the Nginx server, e.g.

lt --port 8080 --path /someproject

Then all requests from https://subdomain.localtunnel.me/* are actually making requests to my http://localhost:8080/someproject/*.

Content-Security-Policy with localtunnel.me

Is there a way to disable Content-Security-Policy with localtunnel.me?

Since localtunnel.me is exposing code on your own machine, it's pretty safe to assume that you trust the host hosted on your own machine. Right now, I'm trying to keep my code as simple as possible by having all the source code inlined with the HTML. Everything works fine with localhost, but not with localtunnel.me because the server used returns script-src 'none' for the Content-Security-Policy header. Can we get an option to disable this feature?

I reckon that the localtunnel.me server doesn't need to add any headers and can instead be configured to pass through any headers from the server on your own machine. e.g. if I want to set the CSP policy header, I can do it on my localhost server, and localtunnel.me just passes that header through unadulterated.

Does client could only init connection via the 80 port?

For the first communication between the client and server, it seems there is no way to set up the port other than the default 80 port.

For a server:

bin/server --port 1234

There is no way for the client to init connection to it. Currently I am using nginx reverse proxy to solve this issues.

I understand the design as most remote requests will come to the 80 port, and the server must listen for that port.

I suggest to use setup a config variable to make the client and server init their communication on a different port.

`bin/lt` hides stack traces

When lt crashes it just logs the string representation of the error (console.error(err);). This makes it very hard to debug, it would be very useful to have the whole stack trace, (console.error(err.stack)).

I propose to change to the following. Since error is a special event in node, emitting it will cause it to throw and exit with a exit code indicating error, and print the stack trace.

lt_client(opt.port, opt, function(err, tunnel) {
    if (err) { throw err; }
    console.log('your url is: %s', tunnel.url);
});

Wordpress not working

When I run Wordpress using Mamp on localhost, port 8888, custom URL http://localhost:8888/wordpress and I try to tunnel that using $ lt --port 8888, I will just see the tree at http://localhost:8888 with a link to folder wordpress. When I click that however, loading will fail.

How can I forward my local Wordpress installation using localtunnel?

Error while run localtunnel command lt

I got error while run lt

pinakin@pinakin:~$ lt

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Cannot read property 'prototype' of undefined
at Object.inherits (util.js:511:43)
at Object. (/usr/local/lib/node_modules/localtunnel/client.js:25:6)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:32)
at Function._load (module.js:308:12)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at Object. (/usr/local/lib/node_modules/localtunnel/bin/client:2:17)
at Module._compile (module.js:441:26)

Can you please help to sort out this issue.
I am using ubuntu : 12.04 (precise) 64-bit

localtunnel error: no active client for ....

Hi,

I'm following all instructions and my tunnels used to work. I haven't changed anything, but now tunnels that should work are showing "localtunnel error: no active client for ....".

Is the service down? It would be nice if it gave a different error when the service itself is down, vs if it thinks my local service is not responding (which it is).

localtunnel(port[, opts, fn) signature

With fn receiving err as the initial setup/connection error, and a Tunnel object with url properties, which emits error for session-related tunnel errors.

Log and display requests/hits when a tunnel is running

Would be super cool with a verbose mode that displayed all requests to the tunnel currently running.

Kind of like heroku logs etc. does it:

$ lt --port 4000
your url is: https://yxyrzgfrbx.localtunnel.me

2014-04-14T10:10:06.747431+00:00 method=GET path=/ connect=1ms service=37ms status=200 bytes=290

Allow dashes in custom subdomain

Please -- this would make it clearer and easier when namespacing.

Is there any technical reason to restrict subdomain requests to only 4-20 alphanumerics?

npm ERR: 'peerDependencies' errors with grunt-bbb-requirejs on install

Hi there, I'm eager to check out localtunnel but am getting this error after my npm install. Wondering if it's particular to my machine, as a coworker had no issues, or if this is something you can help to clarify.

I can't spot anything on a brief pass in your package.json that would cause the below to manifest.

Many thanks...

npm ERR! peerinvalid The package grunt-bbb-requirejs does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer [email protected] wants [email protected]

npm ERR! System Darwin 11.4.2
npm ERR! command "/usr/local/Cellar/node/0.10.26/bin/node" "/usr/local/bin/npm" "install" "-g" "localtunnel"

RangeError: Maximum call stack size exceeded

net.js:0
(function (exports, require, module, __filename, __dirname) { // Copyright Joy
^
RangeError: Maximum call stack size exceeded

I got this when having a local tunnel up and running for ~2h. I think you need to add setImmediate(function () { ... }); somewhere.

Is https://localhost supported?

I'm running my server as a https of localhost - special node.js server - and it seems that I only get 504 bad gateway errors. I think this is because the following startup: lt --port 3443 still tries to redirect down to http://localhost:3443. Is there any way of having a https option available?

I probably shouldn't develop in https with self signed certs, but as I use node I have redirects in to force https.

EADDRNOTAVAIL error

Hello,

I'm running a local server using MAMP (localhost on port 80) on my Mac OS X 10.7.5.

Executing sudo lt --port 8000 (also tried ports 8888, 80, 8001 and 8002) throws following error in the console:

sudo lt --port 8888
your url is: http://izcw.localtunnel.me

events.js:48
        throw arguments[1]; // Unhandled 'error' event
                       ^
Error: connect EADDRNOTAVAIL
    at errnoException (net.js:670:11)
    at connect (net.js:548:19)
    at Socket.connect (net.js:613:5)
    at Object.<anonymous> (net.js:77:12)
    at conn (/usr/local/lib/node_modules/localtunnel/client.js:59:30)
    at /usr/local/lib/node_modules/localtunnel/client.js:101:10
    at /usr/local/lib/node_modules/localtunnel/client.js:140:17
    at Request._callback (/usr/local/lib/node_modules/localtunnel/client.js:15:9)
    at Request.callback (/usr/local/lib/node_modules/localtunnel/node_modules/request/main.js:122:22)
    at Request.<anonymous> (native)

Am I doing something wrong or is there a bug?

Thanks,
Roland

Permit more than just HTTP?

An option to allow a direct socket connection would be nice, for example, if I wish to permit someone to access my box via SSH/FTP/whatever, being able to forward those protocols would be nice.

Have the default listener set to 80 on the localtunnel.me 'forwarded host' or whatever port works for you.

Just an idea, but it would be a very nice function :)

Having trouble overriding localhost

I’m trying to override local host when calling the tunnel.
I’m running Apache server with custom host (e.g. project.loc) but every time I try to create tunnel (e.g. lt --port 80 --local-host project.loc) I get redirected to default localhost. Default localhost displays OK, but it’s not the content which Apache virtual hosts points to when you call project.loc.

Should I be running something other than Apache for this? Maybe some other port? Overriding to some publicly available URL like google.com works OK.

Tunnel not successfully established with uppercase letters

Try to create a subdomain like Alexander. It will work, but when you try to connect, it says:

localtunnel error: no active client for 'alexander'

I believe this is because you have a redirect rule to all lowercase subdomains, which doesn't work. The fix could be on the side of the website, or just making all domains lowercase, or throwing an error when using any uppercase letters.

Data not passing through

Hi there. Awesome product.

Unfortunately, at the moment I cannot get any output from my tunnel in my browser. Instead it just seems to sit and spin with no data every getting returned. I get a url back when I run the client from the shell. I can ping that url. It resolves to the same IP as localtunnel.me. I assume this is correct.

Some background: I am using the built in PHP server on my local computer and am using port 8080.

Thanks!

subdomains?

This looks pretty amazing, but I was wondering if there is a way to make it do subdomains. We're working with several apps that "for reals" live on subdomains on the same tld, but for local dev run on separate ports. It would be superuseful if localtunnel had some like this:

var client = localtunnel.connect({
    // the localtunnel server
    host: 'http://localtunnel.me',
    // (optional) subdomain for this connection
    subdomain: 'projectname',
    // your local application port
    port: 12345
});

so that connecting to http://projectname.localtunnel.me went to the node instance running on 127.0.0.1:12345

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.