It is now fairly common among developers to set up a local environment for testing web applications.
Whether you’re using Apache, Mongrel, or the App Engine SDK, it has become apparent that having a production-like environment on your local machine is beneficial as It allows you to iteratively code and debug without needing to deploy to a production server.
But you can take it a step further with a tool like LocalTunnel.
LocalTunnel is an open-source network tool that allows you to share your Localhost with the world for quick, easy testing. It's easy to set up, and it provides you with a unique, publicly accessible URL that will proxy all requests to your locally running web server. No more sharing screens to demo a product to your team members!
This guide assumes that you have Nodejs installed and that you can run bash commands on your terminal. If you don’t have Node installed, you can do so with the npm documentation.
Install LocalTunnel with NPM
To start working with LocalTunnel, install the LocalTunnel client on your machine using the command npm install -g localtunnel
which installs LocalTunnel globally on your machine.
After running the command, you should see terminal messages indicating the progress of the installation and a message confirming that the installation was successful if it was successfully installed.
You can verify your installation by running the command lt —-version
, which should return the LocalTunnel client's version number.
Run LocalTunnel
Once you have successfully installed the tool, run lt—-port 3000
in your terminal to start a LocalTunnel session. This command should generate LocalTunnel’s default URL, which looks like this: “https://[random-characters].loca.lt”.
Visiting this address in your browser should prompt you for a password. Your password is the public IP of your machine (or VPN public IP, if you’re connected to one). You can get your public IP by visiting https://loca.lt/mytunnelpassword in your browser.
Note: You don’t necessarily have to use port 3000 when running the LocalTunnel command. You can route it to any port running on your local machine. To use LocalTunnel through an API for integration or other automation tests, refer to the official documentation.
Here’s an overview of how LocalTunnel works:
Of course, LocalTunnel isn’t the only tool available to make your local applications public. Other tools include Ngrok which I mentioned earlier, Serveo, PageKite and SSH Tunneling.
LocalTunnel is a go-to tool for sharing your local websites or testing setups with others. It's easy to set up and doesn't cost money, helping teams collaborate without hassle.
It is important to note, though, that using LocalTunnel comes with security risks since you’ll be exposing your local machine to the public. So ensure that you only use it for development and testing.
With that being said, Happy Testing!