Instantly share code, notes, and snippets.

Embed
What would you like to do?
Installing ngrok on Mac

#Installing ngrok on OSX

  1. Download ngrok
  2. Unzip it to your Applications directory
  3. Create a symlink (instructions below)

Creating a symlink to ngrok

Run the following two commands in Terminal to create the symlink.

# cd into your local bin directory
cd /usr/local/bin

# create symlink
ln -s /Applications/ngrok ngrok

This will allow you to run the ngrok command from any directory while in the terminal. Without the symlink, you would need to either cd into the Applications directory (or wherever you installed the executable) or reference ngrok with its full path every time (e.g. /Applications/ngrok 5000)

Using ngrok

The easiest way to use ngrok to tunnel into your localhost is if your local project is running on a specific port (e.g. not using named vhosts). You just run ngrok http [port number].

You can quickly boot up a local webserver using ruby. cd into the project's root directory and run ruby -run -e httpd . -p [port number].

@milocosmopolitan

This comment has been minimized.

milocosmopolitan commented Aug 19, 2016

While downloading the zip file from ngrok website and installing was not successful, this command line worked for me.
$ brew cask install ngrok

@thesunwave

This comment has been minimized.

thesunwave commented Feb 13, 2017

@milocosmopolitan as far i know, cask have an old version 1.x, but latest 2.x

@Omavibot

This comment has been minimized.

Omavibot commented Mar 3, 2017

@milocosmopolitan from then on which directory did you have to use to execute ngrok commands?

@jayaram171992

This comment has been minimized.

jayaram171992 commented Mar 14, 2017

http://ngrok.com was unreachable for me. So I did npm install -g ngrok and it works too

@pbrooker

This comment has been minimized.

pbrooker commented May 14, 2017

jayaram1711992 offers a correct option. Works quite smoothly.

@mitchellporter

This comment has been minimized.

mitchellporter commented May 26, 2017

Works perfectly thanks @wosephjeber

@shamoman

This comment has been minimized.

shamoman commented Jun 21, 2017

i want change the default port 80 to 8080, but i do not know how to change it, any one can help me?

@ronanmccoy

This comment has been minimized.

ronanmccoy commented Jun 29, 2017

@shamoman, if I understand your question correctly, ngrok allows you to change the port when you execute:

ngrok http -hostname=dev.example.com 8080 or ngrok http 8080

Does that not suffice?

If not you can try using a configuration file, see the docs here: https://ngrok.com/docs#config

@rcastro-tyc

This comment has been minimized.

rcastro-tyc commented Jul 27, 2017

@wosephjeber nice gist ! Works fine for me !

@nickcobbett

This comment has been minimized.

nickcobbett commented Aug 11, 2017

Thank you!

@floracitrus

This comment has been minimized.

floracitrus commented Sep 21, 2017

Thank you @jayaram171992 that works for me

@nicooprat

This comment has been minimized.

nicooprat commented Oct 11, 2017

npm i -g ngrok 👍

@roblav96

This comment has been minimized.

roblav96 commented Feb 2, 2018

@nicooprat you are winning!

@artur79

This comment has been minimized.

artur79 commented Feb 22, 2018

@thesunwave cask has 2.2.8 currently

@EstebanMarin

This comment has been minimized.

EstebanMarin commented May 24, 2018

yes npm i -g ngrok much better. That way is accessed globally

@toddpla

This comment has been minimized.

toddpla commented Oct 15, 2018

While downloading the zip file from ngrok website and installing was not successful, this command line worked for me.
$ brew cask install ngrok

Worked for me. Thanks

@joeyfigaro

This comment has been minimized.

joeyfigaro commented Nov 12, 2018

Error: Cask 'ngrok' does not have a sha256 checksum defined and was not installed.

^ For those using require-sha for homebrew

@dlaweb

This comment has been minimized.

dlaweb commented Nov 26, 2018

Has anyone ever encountered this problem ? :
The error encountered was: dial tcp [::1]:8080: getsockopt: connection refused

@JacobMGEvans

This comment has been minimized.

JacobMGEvans commented Nov 26, 2018

brew cask install ngrok gave me the 2.x version and was much easier than their suggested means of installation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment