Sharing a Local Site Online With NGrok

Last modified: 
Wednesday, July 27th, 2016

What is ngrok?

Ngrok is a service which allows you to expose a local website to the internet. Ngrok uses HTTP tunnels, which allow you to share a site without the need for port forwarding on your router. This means local sites can be shared from libraries, corporate networks, coffee shops, and the like.

Download and install ngrok from here.

Basic Usage

Expose a site on port 80:

ngrok http 80

This will return something like the following:

Tunnel Status                 online                                                                                                                                                                
Version                       2.1.3                                                                                                                                                                 
Region                        United States (us)                                                                                                                                                    
Web Interface                                                                                                                                                        
Forwarding           -> localhost:80                                                                                                                              
Forwarding           -> localhost:80                                                                                                                             

The Web Interface URL leads to a dashboard where you can monitor connection and usage info.

The Forwarding URLs allow access to your site over http and https. Since we haven't specified an encrypted endpoint, the ngrok https tunnel will point to port 80 on your local, which may cause unexpected behavior.

Tunnel to a Virtual Domain

Your local setup may support assorted virtual host domains such as myapp.locahost, prototype.localhost, etc. You point an ngrok tunnel to one of these virtual hosts using the -host-header flag.

ngrok http -host-header=myapp.localhost 80

The operator of this site makes no claims, promises, or guarantees of the accuracy, completeness, originality, uniqueness, or even general adequacy of the contents herein and expressly disclaims liability for errors and omissions in the contents of this website.