Installing ngrok on OSX

You really want to try this if you all of a sudden have a localhost website to share to others but it’s troublesome to get onto the same network and lookup IP and stuff.

To install ngrok, just run the following. More details here.

brew cask install ngrok

Then have your localhost running. Here is a sample command to share your local directory. You can pick any port number. Let’s pick 8080 for example.

ruby -run -e httpd . -p 8080

Then involve ngrok

ngrok http 8080

You will see something like this

ngrok by @inconshreveable                                                       
                                                                                
Session Status                online                                            
Session Expires               7 hours, 59 minutes                               
Version                       2.3.35                                            
Region                        United States (us)                                
Web Interface                 http://127.0.0.1:4040                             
Forwarding                    http://abc123ef.ngrok.io -> http://localhost:8080 
Forwarding                    https://abc123ef.ngrok.io -> http://localhost:8080
                                                                                
Connections                   ttl     opn     rt1     rt5     p50     p90       
                              2       1       0.02    0.01    0.23    0.45      
                                                                                
HTTP Requests                                                                   
-------------                                                                   
                                                                                
GET /favicon.ico               404 Not Found                                    
GET /                          200 OK                                                

A publicly available URL, actually two, are created: https:// abc123ef.ngrok.io The abc123ef part will be different each time you involve ngrok. Now just send this URL to others and they will be able to access your localhost website.

You can also examine the incoming traffic at http:// 127.0.0.1:4040

Stopping ngrok is as easy as Ctrl-C.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s