Expose your local ๐Ÿ’ป web server to the world ๐ŸŒ
Giorgos Kontopoulos ๐Ÿ‘€

Giorgos Kontopoulos ๐Ÿ‘€ @giorgosk

About: Remote Web engineer. Mostly frontend.

Location:
Chios, Greece
Joined:
Jan 19, 2017

Expose your local ๐Ÿ’ป web server to the world ๐ŸŒ

Publish Date: Jan 17 '20
206 34

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.

Comments 34 total

  • Biswajit Biswas
    Biswajit BiswasJan 17, 2020

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

    • Giorgos Kontopoulos ๐Ÿ‘€
      Giorgos Kontopoulos ๐Ÿ‘€Jan 17, 2020

      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

      • Biswajit Biswas
        Biswajit BiswasJan 17, 2020

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

        • Giorgos Kontopoulos ๐Ÿ‘€
          Giorgos Kontopoulos ๐Ÿ‘€Jan 17, 2020

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

  • Andreas K. Weber
    Andreas K. WeberJan 17, 2020

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

    ngrok.com

    • Giorgos Kontopoulos ๐Ÿ‘€
      Giorgos Kontopoulos ๐Ÿ‘€Jan 17, 2020

      @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

      • Andreas K. Weber
        Andreas K. WeberJan 17, 2020

        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.

        • Giorgos Kontopoulos ๐Ÿ‘€
          Giorgos Kontopoulos ๐Ÿ‘€Jan 17, 2020

          @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

    • Devan
      DevanJan 17, 2020

      Yeah, ngrok is way simpler to use

      • Giorgos Kontopoulos ๐Ÿ‘€
        Giorgos Kontopoulos ๐Ÿ‘€Jan 17, 2020

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

        • Devan
          DevanJan 17, 2020

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

          ngrok http 80

  • Leandro Ardissone
    Leandro ArdissoneJan 17, 2020

    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.

    • Giorgos Kontopoulos ๐Ÿ‘€
      Giorgos Kontopoulos ๐Ÿ‘€Jan 17, 2020

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

  • George Jempty
    George JemptyJan 17, 2020

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

    • Giorgos Kontopoulos ๐Ÿ‘€
      Giorgos Kontopoulos ๐Ÿ‘€Jan 17, 2020

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

      • George Jempty
        George JemptyJan 17, 2020

        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?

        • Giorgos Kontopoulos ๐Ÿ‘€
          Giorgos Kontopoulos ๐Ÿ‘€Jan 17, 2020

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

          • George Jempty
            George JemptyJan 17, 2020

            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.

            • Giorgos Kontopoulos ๐Ÿ‘€
              Giorgos Kontopoulos ๐Ÿ‘€Jan 17, 2020

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

  • Bennett Dungan
    Bennett DunganJan 17, 2020

    Whoa, very cool. Will definitely give this a try

  • Jason C. McDonald
    Jason C. McDonaldJan 18, 2020

    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.

    • Giorgos Kontopoulos ๐Ÿ‘€
      Giorgos Kontopoulos ๐Ÿ‘€Jan 18, 2020

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

    • Joris Griffioen
      Joris GriffioenJan 18, 2020

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

  • Faiz Azhar
    Faiz AzharJan 18, 2020

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

  • Hanan Hamza
    Hanan HamzaJan 18, 2020

    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

  • Ben Sinclair
    Ben SinclairJan 19, 2020

    The first "big" one of these I remember using was localtunnel, which is just the same sort of ssh wrapper. For some reason, when things like ngrok came out everyone forgot about it though.

  • Cicada1033โžฟ
    Cicada1033โžฟJul 17, 2020

    very easy to setup,thanks :)

  • zecka
    zeckaOct 19, 2020

    What's append to serveo ? Is it dead ?

  • Burak ฤฐลŸleyici
    Burak ฤฐลŸleyiciOct 23, 2022

    Localtonet is also one of the good solutions.

Add comment