Home Command line utilities Localtunnel – Make Your Local Server Accessible Online

Localtunnel – Make Your Local Server Accessible Online

By sk
Published: Last Updated on 5.7K views

Let us say you just have created a beautiful website on your local development system. The client wants to see your work. What will you do? You can either host the website online, so the client can view it. Or, screenshot each page of the website and send them to your client. Would you do that? Not necessarily! Meet Localtunnel that allows you to easily share a web service on your local development machine without putting it online or without messing with DNS and firewall settings. It assigns you an unique publicly accessible URL that will proxy all requests to your locally running webserver. To put this simply, you can expose your local development system to real world. In this brief tutorial, I will show you how to make your local server accessible online using Localtunnel in Unix-like systems.

Install Localtunnel

To install Localtunnel on your local development system, you need NodeJS installed on your system. Refer the following link to install NodeJS on Linux systems.

Once NodeJS installed, run the following command to install Localtunnel:

$ sudo npm install -g localtunnel

Make Your Local Server Accessible Online Using Localtunnel

To make your local system accessible from everywhere (assuming your local system is running on port 80), run the following command from your terminal:

$ lt --port 80

Sample output would be:

your url is: https://gczjxjqvuc.localtunnel.me

localtunnel1

That's it. It will connect to the tunnel server, setup the tunnel, and assign you an unique 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 testing your webservice or just sharing your work. You can restart your local server if necessary. Localtunnel is smart enough to detect this and reconnect once it is back.

Here is how I access my local Ubuntu server from online.

Make Your Local Server Accessible Online Using Localtunnel

Make Your Local Server Accessible Online Using Localtunnel

You may find it difficult to remember the URL. To make it much easier to remember, use subdomain (If it is available) as shown below.

$ lt --port 80 --subdomain myubuntu
your url is: https://myubuntu.localtunnel.me

Now, I can access my local Ubuntu system from anywhere using URL: https://myubuntu.localtunnel.me.

localtunnel3

To check Localtunnel version, run:

$ lt --version
 1.8.3

To get help:

$ lt --help
Usage: /usr/local/bin/lt --port [num] <options>

Options:
 -h, --host Upstream server providing forwarding
 [default: "http://localtunnel.me"]
 -s, --subdomain Request this subdomain
 -l, --local-host Tunnel traffic to this host instead of localhost, override
 Host header to this host
 -o, --open opens url in your browser
 -p, --port Internal http server port [required]
 --help Show this help and exit [boolean]
 --version Show version number [boolean]

Resource:

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You May Also Like

4 comments

Emmanuel September 8, 2020 - 4:55 pm

How do you seriously tunnel traffic to a local https server?

Reply
sk September 8, 2020 - 4:58 pm

May be you should try lt --port 443? I haven’t tested it though.

Reply
Emmanuel September 8, 2020 - 5:29 pm

It doesn’t work. The url provided just keeps loading.

Reply
Timo January 2, 2021 - 10:23 pm

@Emmanuel
What is the final solution you landed in to?
I’m on the lookout for trying to HTTPS localhost. localtunnel seems to have this option but its not working – no response after the command.
tinnelto.dev seems to be recently worked on it but not released it, and do not see sufficient response from the owner further.
Looks like only the expensive ngrok is the option. 🙁

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More