Ngrok - expose your localhost to the web

ngrok is a tool that allows you to expose a service from your local network to the public web.

If you want to share a web app running as a development server on your localhost or when you are implementing webhooks sending data to your web app then you can expose your local version and test and debug all of those cases.

Register to get your auth token and access to additional features. The service is free for most use cases and available for macOS, Linux, Windows, and FreeBSD.

After you have downloaded ngrok you should set your auth token, which will give you longer sessions and some extra features:

./ngrok config add-authtoken YOUR_TOKEN

Now we are ready to use ngrok as we see fit.

Using ngrok on web services

If you have a development web server running on your localhost on some specific port then you can expose it with a simple command:

./ngrok http 8080

Where 8080 is our selected port - you can change that to whichever port you are using.

This will create a ngrok session that will expose your app working on localhost:8080 under one of ngroks temporary subdomains. While this is active you can test your app through that subdomain - share the link with other members of the team, configure social media apps that require public URLs to function, configure webhooks endpoints, and much more.

This can also be handy if you want to test your website on other devices, like mobile phones. You can do that via a local network but this is not always available or requires way more setup and in such cases ngrok to the rescue.

And it doesn't have to be limited to only HTTP servers. You can for example create a streaming server, expose it via ngrok and test how it behaves when accessed over the Internet.

Ngrok on production?

Ngrok has more features as well as paid options. You can get permanent subdomains as well as set up ngrok for other tasks like secure access to remote systems, and private networks or manage a network of IoT devices. You can even expose SSH access via ngrok to a device.

You can read more on the solutions page.

Comment article