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.
Written by Lauren
Related protips
17 Responses
A very useful tip. Thanks
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.
to get it work don't forget to install this:
sudo apt-get install ruby ruby1.8-dev rubygems1.8 libopenssl-ruby
Also check out: http://xip.io/ (Created by 37 Signals)
awesome thx!!
Very useful!! Thnx :D
That's nice ! But why python
in tags ? all is ruby tools
Thank you so much.
Great tip!
Deff using this.
@gahtune localtunnel supports python
Awesome tip! gonna give this a go
here's another one https://forwardhq.com/
xip.io only works on a local network
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
localtunnel github readme: "This project is currently down. Please use Ngrok."
ngrok is even easier