Sometimes you may need to test and market your locally hosted applications on the internet while developing in a local environment. Having a tool that allows you to create a tunnel between your local development environment and a remote server using some tunneling services that enables you to share your work, test and deploy hosted application without the need for public infrastructure comes in handy here.
You'll see how to quickly access your local webserver over the internet using Localhost.run in this tutorial.
Localhost.run
Using localhost.run is as simple as running the following ssh command in your terminal to connect an internet domain to an application running locally on port 8080
ssh -R 80:localhost:8080 ssh.localhost.run
you will be presented with the following similar output
Scan the QR code with your mobile and your local server will be accessible in your phone browser.
There are instances you can receive permission denied error due to some ssh key issue, to fix, do the following:
1. change directory to the current user home directory
Cd ~
2. Check if "id_dsa.pub" file exist in your ".ssh" folder
3. If exist, skip to step 5. if not, run ssh-keygen command to generate a public ssh key:
ssh-keygen
4. Follow the screen prompt until the key is generated
5. Add the generated public key to the authorized_key file, which contains public keys for public key authentication:
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
6. Run localhost.run command again:
ssh -R 80:localhost:8080 ssh.localhost.run
While this may seem like a straightforward approach, the free version is however time limited, and may not be suitable if you need to stay longer using it. You will need to create an account to stay longer.
Other services providing similar function include:
-
Ngrok: This provides about 2hours on the free account but requires account registration and adding your authtoken, and starting it is as simple as running
ngrok http 8080
Cloudflare Tunnel: requires account registration
Note
Please know that following this tutorial may introduce a potential for reduced security and privacy. So, use cautiously!
Top comments (3)
A nice guide, thanks! Although i'd recommend to set up a VPN server or expose the port via NAT instead of depending on an external service + it should be faster since its not a proxied connection
Thanks for sharing.
I would like to recommend ServBay, a local server environment. It helps me shorten my development time and testing time.
Hello. If you want to start buying and selling various currencies and start making money from it, I recommend that you pay attention to the service fxclearing.com/, which offers this opportunity. This trading company has gained the attention of many traders because you can easily trade any currency here. Thanks to the optimised interface, all transactions will be carried out quickly and efficiently, so your earnings will be at their best.