DEV Community

Cover image for Expose your local πŸ’» web server to the world 🌐
Giorgos Kontopoulos πŸ‘€
Giorgos Kontopoulos πŸ‘€

Posted on • Edited on

Expose your local πŸ’» web server to the world 🌐

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

And you would wait to get a response like the following

Connect to http://MACHINENAME-7zhx.localhost.run or https://MACHINENAME-7zhx.localhost.run
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

For serveo check with their website before using as they have their ups and downs lately.

All similar services

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)

Collapse
 
andreaksweber profile image
Andreas K. Weber

I've fallen in love with Ngrok to achieve exactly what your post describes:

ngrok.com

Collapse
 
devansvd profile image
Devan

Yeah, ngrok is way simpler to use

Collapse
 
giorgosk profile image
Giorgos Kontopoulos πŸ‘€

@devansvd thanks for stopping by and the comment.
In what ways is ngrok simpler to use, do you care to explain ?

Thread Thread
 
devansvd profile image
Devan • Edited

Maybe a easy to remember command. Never done registration though. Free Link works for 6 hours. Nice article between.

ngrok http 80

Thread Thread
 
giorgosk profile image
Giorgos Kontopoulos πŸ‘€ • Edited

@devansvd I did not realize you can use ngrok without registering, thanks for sharing.

Collapse
 
giorgosk profile image
Giorgos Kontopoulos πŸ‘€ • Edited

@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

Collapse
 
andreaksweber profile image
Andreas K. Weber

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.

Thread Thread
 
giorgosk profile image
Giorgos Kontopoulos πŸ‘€

@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

Collapse
 
dexygen profile image
George Jempty • Edited

"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/

Collapse
 
giorgosk profile image
Giorgos Kontopoulos πŸ‘€

@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 ?

Collapse
 
dexygen profile image
George Jempty

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?

Thread Thread
 
giorgosk profile image
Giorgos Kontopoulos πŸ‘€ • Edited

@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.

Thread Thread
 
dexygen profile image
George Jempty

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.

Thread Thread
 
giorgosk profile image
Giorgos Kontopoulos πŸ‘€ • Edited

@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.

Collapse
 
codemouse92 profile image
Jason C. McDonald • Edited

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.

Collapse
 
griffinsauce profile image
Joris Griffioen

With these tools you're creating an SSH tunnel and serving to the outside world from their host. How would your ISP even know?

Collapse
 
giorgosk profile image
Giorgos Kontopoulos πŸ‘€

@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.

Collapse
 
lardissone profile image
Leandro Ardissone

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.

Collapse
 
giorgosk profile image
Giorgos Kontopoulos πŸ‘€ • Edited

@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.

Collapse
 
jfbiswajit profile image
Biswajit Biswas

Using "Localhost.run" it says "nothing connected here, check your SSH!"
Any solution?

Collapse
 
giorgosk profile image
Giorgos Kontopoulos πŸ‘€ • Edited

run your command with debugging enabled -v like this

ssh -R 80:localhost:3000 ssh.localhost.run -v

and report back with the output might be able to spot what is going on

Collapse
 
jfbiswajit profile image
Biswajit Biswas

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!"

Thread Thread
 
giorgosk profile image
Giorgos Kontopoulos πŸ‘€ • Edited

@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.

Collapse
 
beznet profile image
Bennett Dungan

Whoa, very cool. Will definitely give this a try

Collapse
 
giorgosk profile image
Giorgos Kontopoulos πŸ‘€

@beznet I was hoping for people to find useful/cool thanks for stopping by and the comments.

Collapse
 
whatthehanan profile image
Hanan Hamza

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

Collapse
 
giorgosk profile image
Giorgos Kontopoulos πŸ‘€

@whatthehanan thanks for stopping by and for your addition. Indeed it make life easier if one is using this technique a lot.

Collapse
 
gabanz profile image
Faiz Azhar

Also worth mentioning... Cloudflare Argo Tunnel developers.cloudflare.com/argo-tun... can be used with or without registering for an account

Collapse
 
giorgosk profile image
Giorgos Kontopoulos πŸ‘€

@gabanz thanks for the comment. Added cloudflare argo tunnel to the list of similar services at the end of the post.

Collapse
 
spidydev profile image
Cicada1033➿

very easy to setup,thanks :)

Collapse
 
zecka profile image
zecka

What's append to serveo ? Is it dead ?

Collapse
 
giorgosk profile image
Giorgos Kontopoulos πŸ‘€

Yes seems to be not working, I took a note and edited the post, thanks for posting.