Why ?
Web developers (mostly) develop on localhost using our preferred tools and languages and have a local server to test what we build. At times we might need to show a coleague or a client our progress or even test using online test tools such as browserstack.
It might be not worth the effort to deploy on a dev server to test a small change that we made or the process of deploying might be time consuming or might not have time to wait for deployment to finish.
Whatever the reason, no stress there is very easy way to expose our localhost using services such as localhost.run, serveo.net, ngrok.com, no-ip.com and there is probably others.
Perhaps the most well known are ngrok and no-ip.com but last time I checked you had to register to use them and hence I looked for easier ways and discovered the alternatives which I will present below.
For tutorials on how to use ngrok.com and/or no-ip.com I am sure you can find plenty on dev.to or just with a quick search.
How ?
Localhost.run can be used without registering you just need to call a simple command on your terminal
ssh -R 80:localhost:8080 ssh.localhost.run
Where 8080 is assumed to be the listening port of your local server.
Here is a simple example. Suppose you have your local development server running on port 3000 so you are testing things out by visting localhost:3000
.
On your terminal you would run
ssh -R 80:localhost:3000 ssh.localhost.run
And you would wait to get a response like the following
Connect to http://MACHINENAME-7zhx.localhost.run or https://MACHINENAME-7zhx.localhost.run
Now you can give 1 of the above links to anyone to access on the internet or use them in you external testing environment.
The server will be running until you terminate the process
That is all, nothing else to it, no need for registering or any other hassle and its a free service.
Similarly you can use serveo.net service with the following command
ssh -R 80:localhost:3000 serveo.net
For serveo check with their website before using as they have their ups and downs lately.
All similar services
- localhost.run (free, no registration)
- serveo.net (appears to be not working, free, no registration)
- ngrok.com (paid, free trial, also free with no registration)
- no-ip.com (paid, free trial, free with monthly re-registration)
- cloudflare argo tunnel (free, no registration)
- dyn.com (paid, free trial)
- Docker tunnel (free, needs setup)
- Docker tunnel (free, needs setup)
- Do it yourself tutorial (free, needs setup)
Please post any other similar services you have in mind or using with any advantages that they might have or send me any corrections to the above list.
WARNING
Some people have raised concerns in the comments that using such a service is actually in violation of your ISP's terms and conditions. This includes usage of any of the alternatives. There is probably a very slight possibility that an ISP can know or detect such a connection though.
Top comments (34)
I've fallen in love with Ngrok to achieve exactly what your post describes:
ngrok.com
Yeah, ngrok is way simpler to use
@devansvd thanks for stopping by and the comment.
In what ways is ngrok simpler to use, do you care to explain ?
Maybe a easy to remember command. Never done registration though. Free Link works for 6 hours. Nice article between.
ngrok http 80
@devansvd I did not realize you can use ngrok without registering, thanks for sharing.
@andreasweber if you don't mind please share your thought we one would choose ngrok over solutions above. Or please share why you have actually fallen in love with it.
Thanks for stopping by
There are several reasons, but I must admit, I've never searched for another tool or solution to expose my local services to the open world, without having the hassle configure a bunch of things. Ngrok just works for my use cases.
I heavily rely on third party software to develop web applications (like Auth0 as identity management solution). Most of them send back status updates via webhooks. To reduce overhead and time spent setting everything up I use the custom subdomains feature of Ngrok. With this enabled I am able to configure a consistent webhook endpoint and don't have to reconfigure my development setup, after I stopped the tunnel, to get it going again.
Moreover, with Ngroks local ui I can capture and replay requests. That's awesome to simulate real webhook requests again and again. With one of the latest updates Ngrok implemented the possibility to modify requests before replaying them.
@andreasweber I guess localhost.run and serveo.net are for simpler use cases than. I did not know ngrok had all those bells and whistles but again I never had the need for them and wanted something very simple.
Thanks for the write up
"Now you can give 1 of the above links to anyone to access on the internet" -- this is against most service providers' terms of service today. Nevertheless the following has been around for 15+ years: dyn.com/remote-access/
@dexygen "this is against most service providers" not sure what this means, care to explain ?
dyn.com/remote-access/ sure is an alternative but you do need register before using or not ?
It means if your internet service provide finds out they can terminate your service. And yeah you probably have to register, but why would that be a deal-breaker?
@dexygen it is not a deal breaker per se but why register for a simple use case like mine
thanks for the constructive comments so far.
Guess I'm just trying to let your readers know a) the potential drawbacks of doing this in general, and b) an alternative, especially since somebody tried your method and it didn't succeed at first. I used to like running servers from my home so I'm interested in general but haven't done so in 15 years or so. Thanks for the article and good luck.
@dexygen it is not my readers only they are reading your comments as well π
I just had this post in my mind and had to let it free. I belive I gave plenty of alternatives (without actual example thought). I am aware that no solution is perfect and therefore all criticism is well received and in good faith.
I am always greatful of insightful comments like yours so please keep it up.
Just a note: Before you expose any server to the web, check the terms of your ISP's service contract! Some ISPs strictly forbid running public servers on certain plans, and can choose to disconnect your service if you violate those terms.
Spectrum is one such example. While I have no complaints about their service β best I've ever seen on all fronts, actually β I do have to pay a little more for Business Internet to be allowed to run a public server. The terms of Residential service just does not permit it.
With these tools you're creating an SSH tunnel and serving to the outside world from their host. How would your ISP even know?
@codemouse92 thanks for your comment, I was not aware this term might be in existence from ISP's side but I was also made aware from another comment earlier thanks for pointing out.
I like these services but I freak a little about security. Specially this one doesn't have any kind of Privacy statement on their website.
I would prefer something hosted by myself.
There may be some docker images to do that by yourself like: docker-tunnel, docker-tunnel (2), etc.
@lardissone The way I see this used is for a few minutes running where I need to test a few quick features and then I turn it down again but you are right I would probably not use it for a mission critical web app.
Thanks for mentioning the alternatives though.
Using "Localhost.run" it says "nothing connected here, check your SSH!"
Any solution?
run your command with debugging enabled
-v
like thisand report back with the output might be able to spot what is going on
Thanks for your reply.
But I still having the same problem. my localhost runs on localhost:80
so I ran this command: "ssh -R 80:localhost:80 ssh.localhost.run -v"
and got the same message: "Nothing connected here, check your SSH!"
@jfbiswajit Are you running on windows ?
I have seen this message that might be from the developer of localhost.run and describes the same error message but no solution
news.ycombinator.com/item?id=14035132
perhaps the windows is not supported at the moment but I have never seen this, I will see if I can get my hands on a windows machine and give it a try.
You might want to try serveo solution as well.
Whoa, very cool. Will definitely give this a try
@beznet I was hoping for people to find useful/cool thanks for stopping by and the comments.
for bash users you can create a bash alias for it like this:
function localserve(){
ssh -R 80:localhost:"$1" ssh.localhost.run
}
and then use it as localserve 3000
@whatthehanan thanks for stopping by and for your addition. Indeed it make life easier if one is using this technique a lot.
Also worth mentioning... Cloudflare Argo Tunnel developers.cloudflare.com/argo-tun... can be used with or without registering for an account
@gabanz thanks for the comment. Added cloudflare argo tunnel to the list of similar services at the end of the post.
very easy to setup,thanks :)
What's append to serveo ? Is it dead ?
Yes seems to be not working, I took a note and edited the post, thanks for posting.