Read more

Using ngrok for exposing your development server to the internet

Tobias Kraze
December 22, 2021Software engineer at makandra GmbH

Sometimes you need to access a dev server running on localhost from another machine that is not part of the same network. Maybe you want to use your phone to test a web page, but are only in a guest WiFi. In the past, we often used some port forwarding or other techniques to expose the service to the internet.

Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

Enter ngrok, a command line tool that gives you an on-the-fly internet domain routing to your localhost.

On ubuntu, you can install ngrok with sudo snap install ngrok. Then start it using

ngrok http 3000

Image

Now, if you open the http or https URL shown, you will reach your local machine on port 3000.

This can also be useful if you need to test with TLS, without having to jump through the hoops of creating some self-signed TLS certificate.

Note: Ngrok rate limits your requests, but to a reasonable level. They sell pro subscriptions for features like higher request limits, or custom URLs.

Warning

Shut it down after use. The URL is sufficiently random to not be guessable, but exposing your dev server to the internet is generally not the best idea.

In my tests I was not easily able to get a better errors console. It seems ngrok correctly indicates that requests came from a remote IP.

localtunnel

To be able to use ngrok you need an account! As alternative you can also use localtunnel Show archive.org snapshot .

Posted by Tobias Kraze to makandra dev (2021-12-22 09:50)