Navigation Menu

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)

@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