GT4 Design + Web

Dev Tools: NGrok

Dev Tools: NGrok

Dev Tools: NGrok

As a developer, I am always on the look out for cool tools that will make my job that little bit easier.

One of the tasks that I find quite tedious is the process of setting up IIS Express to allow remote connections. This process involves configuring the Windows Firewall and adding entries to the applicationhost.config file to specify the host and port name that the website can be accessed on.

Although it’s not really a complicated process, it’s just more annoying to have to do this for every website/application that I want accessible remotley.

So, how can this be made easier? Step forward... NGrok!

NGrok is an application and service that will allow you to create secure tunnels to your localhost. This is extremly useful for when you want to expose a local server behind a NAT or firewall to the internet. In my case, this was IIS Express.

NGrok will allow development sites to be exposed for various reasons such as allowing a client to quickly view a website/application, live debugging and pointing mobile applications to a resource such as a REST API for testing/developing.

Personally, I have found it especially helpful for implementing WebHooks from other services such as BitBucket and GitHub etc.

To get started using NGrok, all you need to do is download and install NGrok for your desired platform and you should be good to go. It currently comes within a zip file, so all you need to do is unzip the contents and move the ngrok application to your desired location. I moved mine to: C:\Apps\ngrok\

Next, you will need to open up a command prompt or terminal with the working directory set to where the ngrok application file is located and execute the following command:

ngrok http 8080

* 8080 should be substituted for the relevant port number.

If the command executes succesfully, the command prompt should change to display something similar to the following:

NGrok Command Prompt

TIP: It may also be a good idea to add the location of where the ngrok application is located to your System Path. Meaning that you should be able to execute NGrok from a command prompt or terminal, regardless of what the current working directory is.


IIS Express

The first time I used this tool to expose a site hosted through IIS Express, it didn’t seem to work as expected and got the following error message after successfully executing the command and then trying to access the site using the specified URL:

  • Bad Request - Invalid Hostname

This is likely due to how the requests are handled for IIS Express.

So, when using IIS Express, this needs to be done slightly differently as to the normal method as outlined above. Instead of the command above, you should enter the following command:

ngrok http 8080 -host-header="localhost:8080"

* 8080 should be substituted for the relevant port number.


You may also like

There are no related articles.

Twitter Feed