Skip to content

Instantly share code, notes, and snippets.

@wosephjeber
Last active March 22, 2024 15:55
Show Gist options
  • Save wosephjeber/aa174fb851dfe87e644e to your computer and use it in GitHub Desktop.
Save wosephjeber/aa174fb851dfe87e644e to your computer and use it in GitHub Desktop.
Installing ngrok on Mac

Installing ngrok on OSX

For Homebrew v2.6.x and below:

brew cask install ngrok

For Homebrew v2.7.x and above:

brew install --cask ngrok

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].


If you don't want to use Homebrew...

  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)

@IlkhamGaysin
Copy link

brew cask install ngrok worked for me as well. +1

@dev-michael-schmidt
Copy link

brew cask install ngrok worked for me as well++;

@mahendrapk
Copy link

brew cask install ngrok worked for me as well. +1

@Zwimber
Copy link

Zwimber commented Jul 2, 2019

Worked like a charm (brew cask install ngrok )

@robo360
Copy link

robo360 commented Jul 16, 2019

Worked like a charm (brew cask install ngrok )

Does it also make it globally available?

@Zwimber
Copy link

Zwimber commented Jul 16, 2019

Worked like a charm (brew cask install ngrok )

Does it also make it globally available?

Yes

@cyaconi
Copy link

cyaconi commented Sep 26, 2019

brew cask install ngrok is the way! thanks

@wosephjeber
Copy link
Author

Wow, can't believe this 4-year old gist has gotten so much traffic! Now that ngrok is available through Homebrew Cask, that's the simplest way to install it. I'll update the gist.

@romenigld
Copy link

$ brew cask install ngrok
so I'm using rails 6 I put:
$ ngrok http 3000
And put on the file config/enviroments/development.rb:
config.hosts << /.*\.ngrok\.io$/

@modermo
Copy link

modermo commented Jul 3, 2020

Works perfectly.

@jstgermain
Copy link

jstgermain commented Jul 16, 2020

you can just put ngrok in your root instead, and then just run
ngrok HTTP 80
mine is located at ~/ngrok

so do...

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

# create symlink
ln -s ~/ngrok ngrok

@idodekerobo
Copy link

worked great. still not the best w/ terminal commands so the symlink was v helpful. thanks

@dmitriyzyuzin
Copy link

It works, thanks!

@hiramhuang
Copy link

brew cask <command> was deprecated. Use this command to install instead:

brew install --cask ngrok

Homebrew/discussions#340 (comment)

@msudgh
Copy link

msudgh commented Jan 14, 2021

@andrewtheskills
Copy link

@hiramhuang +1 Thanks!

@wosephjeber
Copy link
Author

Awesome, thanks for the heads up @hiramhuang! I've updated the gist accordingly.

@bibstha
Copy link

bibstha commented Jan 27, 2021

brew install ngrok automatically installs ngrok symlink now. But in macOS Big Sur, it will complain that it hasn't been signed and therefore you wont be able to run it.
To get this working, you have to

  1. In terminal: open /usr/local/Caskroom/ngrok/latest/
  2. right click ngrok and click open
  3. Click open again

After this, you can run ngrok as usual from command line.

@jjwang01
Copy link

jjwang01 commented Feb 1, 2021

@bibstha +1 thanks so much!

@alonsoCMrz
Copy link

brew install ngrok automatically installs ngrok symlink now. But in macOS Big Sur, it will complain that it hasn't been signed and therefore you wont be able to run it.
To get this working, you have to

  1. In terminal: open /usr/local/Caskroom/ngrok/latest/
  2. right click ngrok and click open
  3. Click open again

After this, you can run ngrok as usual from command line.

YEAAH that really helped

@roychowdhuryrohit-dev
Copy link

@hiramhuang brew install ngrok installs an older (v2) of ngrok. How do I install the latest (v3) with brew?

@manishbassi
Copy link

manishbassi commented Feb 17, 2021

brew install ngrok automatically installs ngrok symlink now. But in macOS Big Sur, it will complain that it hasn't been signed and therefore you wont be able to run it.
To get this working, you have to

  1. In terminal: open /usr/local/Caskroom/ngrok/latest/
  2. right click ngrok and click open
  3. Click open again

After this, you can run ngrok as usual from command line.

This helped but now, it's saying command not found.
zsh: command not found: ngrok

Basically, it deletes ngrok file when I clicked it on 'open' at Step 3. Can you please help here?

@umarphaarook
Copy link

It worked, thanks

@juandefelix
Copy link

Thank you!

@gitjul
Copy link

gitjul commented Jun 16, 2021

@bibstha thanks!

@Nuporly
Copy link

Nuporly commented Jun 20, 2021

┌──(kali㉿kali)-[/usr/local/bin]
└─$ ln -s ~/ngrok ngrok 1 ⨯
ln: failed to create symbolic link 'ngrok': Permission denied

@anhtuank7c
Copy link

I just simple execute this command brew install ngrok

@fadlisaad
Copy link

On macOS monterey, some command were broken. Please update brew using brew doctor and fix according to the suggested solution. Then install again using brew install ngrok

@greathiago
Copy link

Mac user here, the only that worked for me: sudo npm install --unsafe-perm -g ngrok

@AAdewunmi
Copy link

@wosephjeber ... Worked fine! Thanks 👍

Screenshot

@Limitless-Kode
Copy link

brew install --cask ngrok worked for me

@cjj1120
Copy link

cjj1120 commented Nov 11, 2022

For those that followed the second approach:

# create symlink
ln -s /Applications/ngrok ngrok

If u get permission denied, can try the same command with sudo in front.. worked for me.
and make sure this path (/Applications/ngrok ) is set to where your installed and unzip ngrok is located.

@russorat
Copy link

the correct instructions for installing via homebrew are: brew install ngrok/ngrok/ngrok from https://ngrok.com/download

the casks are out of date and should not be used.

@engagepy
Copy link

engagepy commented May 7, 2023

Worked indeed.

@akshayuppal3
Copy link

the ceritficate is expired so euinox is not working

ngrok - install failed RequestError: Hostname/IP does not match certificate's altnames: Host: bin.equinox.io. is not in the cert's altnames: DNS:c.sni-561-default.ssl.fastly.net
    at ClientRequest.<anonymous> (/Users/aksuppal/node_modules/got/dist/source/core/index.js:970:111)
    at Object.onceWrapper (events.js:520:26)
    at ClientRequest.emit (events.js:412:35)
    at ClientRequest.origin.emit (/Users/aksuppal/node_modules/@szmarczak/http-timer/dist/source/index.js:43:20)
    at TLSSocket.socketErrorListener (_http_client.js:475:9)
    at TLSSocket.emit (events.js:400:28)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)
    at new NodeError (internal/errors.js:322:7)
    at Object.checkServerIdentity (tls.js:347:12)
    at TLSSocket.onConnectSecure (_tls_wrap.js:1525:27)
    at TLSSocket.emit (events.js:400:28)
    at TLSSocket._finishInit (_tls_wrap.js:937:8)
    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:709:12) {
  code: 'ERR_TLS_CERT_ALTNAME_INVALID',
  timings: {
    start: 1693509639041,
    socket: 1693509639041,
    lookup: 1693509644048,
    connect: 1693509644065,
    secureConnect: undefined,
    upload: undefined,
    response: undefined,
    end: undefined,
    error: 1693509644095,
    abort: undefined,
    phases: {
      wait: 0,
      dns: 5007,
      tcp: 17,
      tls: undefined,
      request: undefined,
      firstByte: undefined,
      download: undefined,
      total: 5054
    }
  }
}
npm WARN enoent ENOENT: no such file or directory, open '/Users/aksuppal/package.json'
npm WARN aksuppal No description
npm WARN aksuppal No repository field.
npm WARN aksuppal No README data
npm WARN aksuppal No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ngrok@5.0.0-beta.2 postinstall: `node ./postinstall.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ngrok@5.0.0-beta.2 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/aksuppal/.npm/_logs/2023-08-31T19_20_44_251Z-debug.log
(assort) aksuppal@b0f1d8736ba8 ~ % brew install ngrok/ngrok/ngrok
Error: Download failed on Cask 'ngrok' with message: Failure while executing; `/usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --show-error --user-agent Homebrew/4.1.7\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 13.5.1\)\ curl/8.1.2 --header Accept-Language:\ en --retry 3 --fail --location --silent --head https://bin.equinox.io/a/ktMDMTZpQoX/ngrok-v3-3.3.2-darwin-arm64.zip` exited with 60. Here's the output:
curl: (60) SSL: no alternative certificate subject name matches target host name 'bin.equinox.io'
More details here: https://curl.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.

@russorat
Copy link

PM from ngrok here. I tried to reproduce your issue by running brew install ngrok/ngrok/ngrok and cannot. Are others seeing this?

  ~ ❯ brew install ngrok/ngrok/ngrok                                   3.0.0
Running `brew update --auto-update`...
==> Auto-updated Homebrew!
==> Upgrading 1 outdated package:
ngrok/ngrok/ngrok 3.1.1,an2KvqCaZyY,a -> 3.3.2
==> Upgrading ngrok
==> Downloading https://bin.equinox.io/a/ktMDMTZpQoX/ngrok-v3-3.3.2-darwin-arm64
######################################################################### 100.0%
==> Unlinking Binary '/opt/homebrew/bin/ngrok'
==> Linking Binary 'ngrok' to '/opt/homebrew/bin/ngrok'
==> Purging files for version 3.1.1,an2KvqCaZyY,a of Cask ngrok
🍺  ngrok was successfully upgraded!

@quarkw
Copy link

quarkw commented Oct 25, 2023

PM from ngrok here. I tried to reproduce your issue by running brew install ngrok/ngrok/ngrok and cannot. Are others seeing this?

  ~ ❯ brew install ngrok/ngrok/ngrok                                   3.0.0
Running `brew update --auto-update`...
==> Auto-updated Homebrew!
==> Upgrading 1 outdated package:
ngrok/ngrok/ngrok 3.1.1,an2KvqCaZyY,a -> 3.3.2
==> Upgrading ngrok
==> Downloading https://bin.equinox.io/a/ktMDMTZpQoX/ngrok-v3-3.3.2-darwin-arm64
######################################################################### 100.0%
==> Unlinking Binary '/opt/homebrew/bin/ngrok'
==> Linking Binary 'ngrok' to '/opt/homebrew/bin/ngrok'
==> Purging files for version 3.1.1,an2KvqCaZyY,a of Cask ngrok
🍺  ngrok was successfully upgraded!

It works for me, but I did come across an issue installing through nix and was getting this error:

Warning: 'ngrok/ngrok/ngrok' formula is unreadable: No available formula with the name "ngrok/ngrok/ngrok".
Warning: No available formula with the name "ngrok/ngrok/ngrok".
Installing ngrok/ngrok/ngrok has failed!```

On installing manually I found out the formula is actually a cask, and once I configured nix to install it as a cask it worked. Should the `--cask` flag be added to the install instructions?

@arrenndajo
Copy link

thank you Joe! this finally worked yay

@yash-airon
Copy link

Screenshot 2023-12-21 at 12 26 16 PM Facing this issue while tunneling a process in local Tried multiple things mentioned online but still not working one of them was adding and removing root_cas in ngrok.yml Please help

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