Skip to content

Instantly share code, notes, and snippets.

@wosephjeber
Last active November 14, 2024 09:06
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)

@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! [email protected] postinstall: `node ./postinstall.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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

@sk29110
Copy link

sk29110 commented Jun 3, 2024

I am getting The file “0f807b1ac344169712a2c1367aa97550fda39e9fe1f55d77363a29421f2c25d4--ngrok-v3-3.10.0-stable-darwin-arm64.zip” couldn’t be opened because there is no such file. It seems it failed to unzip ngrok...arm64.zip file on mac

@engagepy
Copy link

engagepy commented Jun 4, 2024 via email

@VitaliyR
Copy link

VitaliyR commented Oct 8, 2024

@russorat Latest mac os fails:

==> Downloading https://bin.equinox.io/a/dW4eR4uyHNy/ngrok-v3-3.16.1-darwin-arm64.zip
curl: (35) LibreSSL/3.3.6: error:1404B42E:SSL routines:ST_CONNECT:tlsv1 alert protocol version

Error: Download failed on Cask 'ngrok' with message: Download failed: https://bin.equinox.io/a/dW4eR4uyHNy/ngrok-v3-3.16.1-darwin-arm64.zip

@russorat
Copy link

russorat commented Oct 8, 2024

@VitaliyR thanks for posting. I couldn't repro this, so maybe it was just transient. Could you try again?

==> Downloading https://bin.equinox.io/a/dW4eR4uyHNy/ngrok-v3-3.16.1-stable-darw
######################################################################### 100.0%
==> Unlinking Binary '/opt/homebrew/bin/ngrok'
==> Linking Binary 'ngrok' to '/opt/homebrew/bin/ngrok'
==> Purging files for version 3.3.2 of Cask ngrok
🍺  ngrok was successfully upgraded!

@VitaliyR
Copy link

VitaliyR commented Oct 8, 2024

brew install ngrok
==> Downloading https://formulae.brew.sh/api/formula.jws.json
######################################################################################################################################################################################################################################################### 100.0%
==> Downloading https://formulae.brew.sh/api/cask.jws.json
######################################################################################################################################################################################################################################################### 100.0%
==> Caveats
To install shell completions, add this to your profile:
  if command -v ngrok &>/dev/null; then
    eval "$(ngrok completion)"
  fi

==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-cask/88c47925c27708227907c551ed381c65f8aa6626/Casks/n/ngrok.rb
######################################################################################################################################################################################################################################################### 100.0%
==> Downloading https://bin.equinox.io/a/dW4eR4uyHNy/ngrok-v3-3.16.1-stable-darwin-arm64.zip
curl: (35) LibreSSL/3.3.6: error:1404B42E:SSL routines:ST_CONNECT:tlsv1 alert protocol version

Error: Download failed on Cask 'ngrok' with message: Download failed: https://bin.equinox.io/a/dW4eR4uyHNy/ngrok-v3-3.16.1-stable-darwin-arm64.zip
brew install ngrok/ngrok/ngrok
==> Auto-updating Homebrew...
Adjust how often this is run with HOMEBREW_AUTO_UPDATE_SECS or disable with
HOMEBREW_NO_AUTO_UPDATE. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/services).
No changes to formulae or casks.

==> Downloading https://bin.equinox.io/a/dW4eR4uyHNy/ngrok-v3-3.16.1-darwin-arm64.zip
curl: (35) LibreSSL/3.3.6: error:1404B42E:SSL routines:ST_CONNECT:tlsv1 alert protocol version

Error: Download failed on Cask 'ngrok' with message: Download failed: https://bin.equinox.io/a/dW4eR4uyHNy/ngrok-v3-3.16.1-darwin-arm64.zip

Still no luck, also it's arm while you have non-arm as far as I can tell from your logs.

Have you tried arm version?

@russorat
Copy link

russorat commented Oct 8, 2024

thanks! sorry my output was cut off, but i was also using the arm64 version. I see another report of this as well: ngrok/homebrew-ngrok#35

I tried curling the exact endpoint with no issues. I checked the cert attached to bin.equinox.io and is seems to be valid, so i'm not sure what's happening here. I will keep looking.

  ~ ❯ curl -O https://bin.equinox.io/a/dW4eR4uyHNy/ngrok-v3-3.16.1-darwin-arm64.zip              ✘ INT  25s  3.0.0
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 8493k  100 8493k    0     0   148k      0  0:00:57  0:00:57 --:--:--  184k
  ~ ❯                                                                                                   57s  3.0.0
  ~ ❯                                                                                                         3.0.0
  ~ ❯                                                                                                         3.0.0
  ~ ❯ curl --insecure -vvI https://bin.equinox.io/a/dW4eR4uyHNy/ngrok-v3-3.16.1-darwin-arm64.zip 2>&1 | awk 'BEGIN { cert=0 } /^\* SSL connection/ { cert=1 } /^\*/ { if (cert) print }'

* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256 / x25519 / RSASSA-PSS
* ALPN: server did not agree on a protocol. Uses default.
* Server certificate:
*  subject: CN=bin.equinox.io
*  start date: Sep  6 23:46:44 2024 GMT
*  expire date: Dec  5 23:46:43 2024 GMT
*  issuer: C=US; O=Let's Encrypt; CN=R10
*  SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
*   Certificate level 0: Public key type RSA (2048/112 Bits/secBits), signed using sha256WithRSAEncryption
*   Certificate level 1: Public key type RSA (2048/112 Bits/secBits), signed using sha256WithRSAEncryption
* using HTTP/1.x
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* Request completely sent off
* Connection #0 to host bin.equinox.io left intact

@russorat
Copy link

russorat commented Oct 8, 2024

what does something like this show for you?
openssl s_client -connect bin.equinox.io:443 </dev/null 2>/dev/null | openssl x509 -inform pem -text

@VitaliyR
Copy link

VitaliyR commented Oct 8, 2024

@russorat Could not find certificate from <stdin>

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