question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Crashing after a few minutes

See original GitHub issue
events.js:85
       throw er; // Unhandled 'error' event
            ^
Error: connection refused: localtunnel.me:37302 (check your firewall settings)
    at Socket.<anonymous> (/usr/local/lib/node_modules/localtunnel/lib/TunnelCluster.js:45:32)
    at Socket.emit (events.js:107:17)
    at net.js:451:14
    at process._tickCallback (node.js:355:11)

I keep getting this error repeatedly on multiple instances of localtunnel but I can’t really pin down what’s causing it. I can’t imagine that the connection is actually getting refused because the tunnel starts up and works normally for however many minutes until it decides to stop working. Is there any way to get it to retry instead of just crashing and closing the tunnel? Right now this is making it really unreliable to use localtunnel because I can’t maintain the connection for any extended period of time.

Thoughts? Solutions?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:20
  • Comments:45 (4 by maintainers)

github_iconTop GitHub Comments

15reactions
dpkonofacommented, Jul 23, 2015

ngrok is great, but I’m not paying $5/month just to get custom subdomains.

12reactions
michaelkeenancommented, May 25, 2016

I use a Ruby script that restarts localtunnel when it crashes (edit: fixed bug that Dave84c pointed out):

require 'optparse'

options = {:subdomain => 'defaultdomain', :port => 3000}

parser = OptionParser.new do|opts|
    opts.banner = "Usage: localtunnel.rb [options]"
    opts.on('-s', '--subdomain subdomain', 'Subdomain') do |subdomain|
        options[:subdomain] = subdomain;
    end

    opts.on('-p', '--port port', 'Port') do |port|
        options[:port] = port;
    end

    opts.on('-h', '--help', 'Displays Help') do
        puts opts
        exit
    end
end

parser.parse!

def ordinal(number)
  abs_number = number.to_i.abs

  if (11..13).include?(abs_number % 100)
    "th"
  else
    case abs_number % 10
      when 1; "st"
      when 2; "nd"
      when 3; "rd"
      else    "th"
    end
  end
end

def ordinalize(number)
  "#{number}#{ordinal(number)}"
end

launch_count = 0

while true
    launch_count += 1
    puts "Running localtunnel for the #{ordinalize(launch_count)} time"
    `lt --port #{options[:port]} --subdomain #{options[:subdomain]}`
end

I’ve been running this for a couple of days, and it’s restarted it 218 times. There must be occasional disruptions, but I haven’t noticed them.

ETA: You’ll need Ruby to run that script. Ruby comes on OSX and on most Linux distributions (not sure about Windows), so it should just run if you save it as a Ruby file. For example, if you save it as localtunnel.rb, you should be able to run it with:

ruby localtunnel.rb --port 3000 --subdomain yourdomainhere

Read more comments on GitHub >

github_iconTop Results From Across the Web

Windows crashing every morning after a few minutes
Method 2. Run memory diagnostic tool: The memory diagnostic tool is a RAM test to check if there are any issues with RAM....
Read more >
Games keep crashing after 5-10 minutes : r/buildapc - Reddit
My games would last maybe 5 - 10 minutes before crashing as well, although cyberpunk was by far the worst offender crashing almost...
Read more >
Steam games keep crashing after 5-10 minutes of play. How ...
A crash after 5–10 minutes on PC games typically means either your CPU or GPU aren't properly cooled. Check that all the fans...
Read more >
Why Computer crashes after a few minutes in game
The reason behind computer crashes after playing a game 5 minutes & the Solution for them. ... 1. Your graphics card has failed....
Read more >
[Problem Solved] Game Keeps Crashing After Few Minutes
I need a little help here, my game keeps crashing after a few minutes of play. I tried it with multiple modules, multiple...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found