Accesing a URL on localhost from the internet with ngrok

Posted by Brian Porter on May 17, 2020

Have you ever needed to expose a URL from you local development machine to the internet in order to test something, or let someone else take a quick look?

I hate messing with my router, and trying to open up a URL through my firewall or NAT - especially if it is a one time thing for testing.

A friend put me on to ngrok - (https://www.ngrok.com) - which sets up one time URL’s while running. There is a free version, but also a professional verison if you want to have more features, like your own domains or regularly using the same URL.

ngrok

A simple one is setup like this:

$ ngrok http 8080

You can also add a password protection with basic auth like this:

$ ngrok http -auth "user:password" 80

Once it is started, you see information in your terminal, along with a monitoring of requests coming in:

Session Status                connecting                                                                                                 Session Status                online                                                                                                 Account                       Brian Porter (Plan: Free)                                                                                      Versionerface                 2.3.35                                                                                                R gio                         United States (us)                                                                                    Web Interface                 http://127.0.0.1:4040
Forwarding                    http://5b551cd9.ngrok.io -> http://localhost:9000                                                         Forwarding                    https://5b551cd9.ngrok.io -> http://localhost:9000

If you made it this far, you may as well follow me: