Posted 30 days ago. Visible to the public. Repeats.

Using ngrok for exposing your development server to the internet

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.

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

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

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for unsupported versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2).

Owner of this card:

Avatar
Tobias Kraze
Last edit:
11 days ago
by Emanuel De
Attachments:
ngrok.png
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Tobias Kraze to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more