Sometimes you need to deploy a web site or app to the Internet. During development, that process is

  1. Make code change
  2. Deploy
  3. Test

This takes time and is difficult to debug.

But what if I could run my code locally and make it accessible to others on the Internet? This would save time in deployment and would make it easier to debug.

That is what ngrok does.

You can download ngrok for free at https://ngrok.com/download (Fig. 1)

ng01-download
Fig. 1

On Windows, this will download a ZIP file containing 1 file: ngrok.exe.

Unzip this file and place it somewhere in your computer's path.

Next, launch your local website or web application, using whatever tools you prefer. I created the node web site shown in Fig. 2 in 5 minutes by following the steps at https://shapeshed.com/creating-a-basic-site-with-node-and-express/.

ng02-localsite
Fig. 2

The syntax to redirect from a public internet URL to a site on your local computer is

ngrok http portnumber

where portnumber is the local port number hosting your site.

My site is hosted on HTTP Port 3000, so we will enter the following command in a Command prompt:

ngrok http 3000

This outputs information as shown in Fig. 3

ng03-ngrokexecuting
Fig. 3

The output displays redirecting URLs. In my case, I can open a new browser window and navigate to either http://6dddba9b.ngrok.io/ or https://6dddba9b.ngrok.io/ and the browser will launch my local site, as shown in Fig. 4.

ng04-redirect
Fig. 4

Others will be able to access your site from the same URL.

Of course, you need an Internet connection for this to work. It's also worth noting that the redirect expires in a few hours, so this is not designed as a permanent solution - only to assist you while you develop and test your site or app.