Last Updated: December 19, 2020
·
10.73K
· poteto

Share localhost with anyone

Ever wanted to quickly share your localhost server with someone else, without going through the hassle of deploying it somewhere?

You’ll be happy to know that there’s a really simple way to do this. First install the localtunnel gem:

$ gem install localtunnel

Next run your localhost server, for example in Rails, using the default WEBrick server:

$ rails s

Or Python:

$ python - m SimpleHTTPServer 8000

The first time you run localtunnel you’ll need to use one of your public SSH keys:

$ localtunnel -k ~/.ssh/id_rsa.pub 8000

You’ll see something like this in your terminal:

➜  project_name git:(develop) localtunnel 8000
   This localtunnel service is brought to you by Twilio.
   Port 8000 is now publicly accessible from http://xxxx.localtunnel.com ...

Now just share http://xxxx.localtunnel.com with whoever needs to see your work.

Subsequently you can just use localtunnel <port> to generate a public URL:

$ localtunnel 8000

And that’s it. Install and setup takes less than 5 minutes, and it works beautifully.

17 Responses
Add your response

A very useful tip. Thanks

over 1 year ago ·

Useful tool in many scenarios I imagine, but it's worth noting that while using any server that will let you bind to 0.0.0.0 you can simply set up forwarding rules on your router/firewall and anyone outside your network should be able to reach it. WEBrick does this by default.

over 1 year ago ·

to get it work don't forget to install this:

sudo apt-get install ruby ruby1.8-dev rubygems1.8 libopenssl-ruby
over 1 year ago ·

Also check out: http://xip.io/ (Created by 37 Signals)

over 1 year ago ·

awesome thx!!

over 1 year ago ·

Very useful!! Thnx :D

over 1 year ago ·

That's nice ! But why python in tags ? all is ruby tools

over 1 year ago ·

Thank you so much.

over 1 year ago ·

Great tip!

over 1 year ago ·

Deff using this.

over 1 year ago ·

@gahtune localtunnel supports python

over 1 year ago ·

Awesome tip! gonna give this a go

over 1 year ago ·

here's another one https://forwardhq.com/

over 1 year ago ·

xip.io only works on a local network

over 1 year ago ·

If you are on the same network you can just take his IP adress and put it on your .htaccess (Allow from xxx.xxx.xxx.xxx)
Then he can go on your IP address and see your loacalhost

over 1 year ago ·

localtunnel github readme: "This project is currently down. Please use Ngrok."

over 1 year ago ·

ngrok is even easier

over 1 year ago ·