Accessing localhost over the internet

logo.pngAs part of the development cycle, accessing your code running on localhost via the internet would be very helpful. Whether it be for an app or for an external SSO test, debugging and tracing on your local machine is a nice tool to have.

Here’s how you can do it:

Sign up for a free account at ngrok.com.

Download and unzip the ngrok.exe client into a location somewhere in your PATH. For example, c:\

On the ngrok site get your “authtoken” (a long random string of letters) and run this:

ngroc3.png

Close Visual Studio, if open. Install the ngrok Visual Studio Extension

Open Visual Studio and the web site you wish to expose to the internet. Choose ngrok from the Tools menu.

ngroc.png

A console window will appear. Ngrok will display a special URL. Use that URL in your device/service that needs to connect to your localhost.  This URL will change every time. To have it lock down, you can pay for a subscription, it’s really cheap. Otherwise the free version works just great.

ngroc2.png

If you wish to use the console instead of the Visual Studio Extension, you can run it like this:

ngroc4.png

The ngrok paid plans have nice features. It’s an affordable service and very helpful. Check them out.

Advertisements