During the development stage, you may deploy the website in a local server. There you can run, develop, and debug the website on a computer, locally. But when your clients need to get access to the website immediately, or if one of the applications you need uses a webhook that has to be online to function, you probably wish that your local server could be accessible online.
Making your local server available online is probably the fastest way to cope with this, especially if you have hundreds of files that you require access to. This is where a tool called localtunnel comes in. With localtunnel we can create a proxy that can tunnel to our local server, making it accessible from anywhere.
Let’s see how this tool works.
The localtunnel that we will be using here comes in a form of a Node.js package. So, you first need to install Node.js using the installer; you can download it in this page. Once Node.js installed, launch Terminal or Command Prompt and type this command below.
npm install -g localtunnel
This command will install localtunnel globally, so it can be accessed in any directories at any level of your computer. Once localtunnel is installed, you should be able to access the
lt command. To test the command, you can type the following (in Terminal or Command Prompt).
If the command works, it should return the localtunnel version installed in your computer, like so.
Alternately, you can also type
lt -help. Like in any Help menu of an application, this particular command will return the list of options and guide on using localtunnel.
You can use localtunnel MAMP or WAMP; two applications that are the most popular for Mac and Windows to run local server. Assuming that the URL of your local server is
http://localhost/ without the port number that follows, you can type the command using 80 as the port number.
lt -port 80
The localtunnel will generate a randomized subdomain name, in which you can access your local server anywhere, like this.
If you want to make the subdomain easy to remember, you can add -subdomain parameter following the port number. This example below will generate
lt -port 80 -subdomain hongkiat
Localtunnel also support Virtual Host. By default, when you run
lt -port 80 command, localtunnel will pick
localhost as the address to connect with. If you have created a Virtual Host with the name of, for example,
development.dev, you can tell localtunnel to connect to that address instead of
localhost using the
Put it all together, and you can type:
lt -port 80 -subdomain hongkiat -local-host hongkiat.dev
The command above will proxy
hongkiat.dev that can be accessed through