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 web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
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)