169

I'm trying to install ngrok (which I've been using for a while on Windows with no issues) on my 1 week old yosemite and these are the steps I've followed so far.

  1. Downloaded ngrok from here https://ngrok.com/download.

  2. Unziped the file and copied the Unix Executable File into application.

Now from what I understand I just need to open the terminal, move inside the application folder and write ngrok http 80. The result of this is "command not found".

I've even signed up at the ngrok website and run from terminal the command ./ngrok authtoken "blablabla" and the result is "No such file or directory"

Can anyone tell me how to proceed to be able to activate the tunnel with ngrok?

BSMP
  • 4,596
  • 8
  • 33
  • 44
Valina
  • 1,739
  • 2
  • 11
  • 9
  • 15
    Start by making sure you're in the right directory. `ls ngrok` should show you that the file exists. After that, `./ngrok ` should work or at least invoke the right program. – Phillip Mills May 12 '15 at 12:05
  • 1
    Thank you Phillip.. I took for granted that I was in /Application but I wasn't.. I was trying to lunch ngrok from users/USERNAME/applications. To go into the right folder I've just written from terminal "cd /Applications" instead of "cd Application". I guess those are newbie errors. Thank you very much – Valina May 12 '15 at 13:06
  • 3
    A Mac trick is: type "cd " in a terminal window and then drag the folder for the directory you want to be in from Finder to Terminal. What you drag changes from an icon to a text string. – Phillip Mills May 12 '15 at 13:11
  • Nice trick.. It work as well with the command "ls" if you need to see the content of a folder into the terminal. Thanks Phillip ;) – Valina May 12 '15 at 16:42
  • Why not use https://pinggy.io ? Does the same thing without the need to download anything. – Bishakh Ghosh May 09 '23 at 18:17

20 Answers20

330

Short answer: Put the executable file in /usr/local/bin instead of applications. You should now be able to run commands like ngrok http 80.

Long answer: When you type commands like ngrok in the terminal, Macs (and other Unix OSs) look for these programs in the folders specified in your PATH. The PATH is a list of folders that's specified by each user. To check your path, open the terminal and type: echo $PATH.

You'll see output that looks something like: /usr/local/bin:/usr/bin:/bin. This is a : separated list of folders.

So when you type ngrok in the terminal, your Mac will look for this executable in the following folders: /usr/local/bin, /usr/bin/ and /bin.

Read this post if you are interested in learning about why you should prefer usr/local/bin over other folders.

Community
  • 1
  • 1
Hammad Khalid
  • 3,430
  • 1
  • 13
  • 7
108

With Homebrew already installed on your Mac, you can easily install ngrok from the terminal, using this command:

$ brew install --cask ngrok

Then run it from the shell using this command:

$ ngrok http 8000

With this command, you're telling ngrok to basically create a tunnel to your localhost 8000 and assign an internet name host for it. And thats it. You should be good to go.

Michal
  • 459
  • 2
  • 7
  • 25
Vick Swift
  • 2,945
  • 1
  • 15
  • 17
  • 17
    `brew cask install ngrok` was throwing `Error: Unknown command: cask` for me. Turns out the install command has been updated to: `brew install --cask ngrok`. – likesalmon Apr 02 '21 at 17:06
  • 1
    `brew install ngrok/ngrok/ngrok` (per instructions at https://ngrok.com/download) is what worked for me on Apple Silicon; unzipping the download available in the ngrok dashboard (either via finder or terminal) did not work for me. – Allison May 02 '22 at 19:14
  • 1
    Successfully Worked on mac with apple silicon chip ```brew install ngrok/ngrok/ngrok``` – Balanagu Yashwanth Jul 25 '22 at 10:48
  • brew install ngrok --cask – grumpyp Aug 28 '22 at 09:04
83
  • Download the zip file.
  • Unzip it.
  • Open The terminal in the current location (inside unzip folder) where you unzip the file.
  • Execute the following command into the terminal :

    sudo cp ngrok /usr/local/bin          
    

    Now your ngrok execuatable file is successfully copied to the /usr/local/bin directory. Now you are able to run the ngrok command in the terminal

Sanchit Gupta
  • 3,148
  • 2
  • 28
  • 36
32

I have also faced this issue on my MacOS, I used these simple steps and it worked for me.

Just open the terminal and go to your project folder where you what to start ngrok and then unzip downloaded file.

$ unzip /path/to/ngrok.zip

After doing this you don't need to authenticate ngrok, just run this command:

./ngrok  http 80

It should work now.

Saif Al Falah
  • 358
  • 5
  • 16
Anil Yadav
  • 1,086
  • 7
  • 18
28

This is how I got it to work..

For Mac

  1. If you downloaded via a download link, you need to add ngrok path to your .bash_profile or .bashrc whichever one you are using.

For Windows 10 bash:

  1. Download ngrok from https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-windows-amd64.zip
  2. Move executable file ngrok.exe to C:\Windows\system32\ngrok.exe
  3. Add Environment Variables via UI (search for "Edit the environment variables for your account" in the search bar next to windows logo => double click on Path under Users Variables for yourusername => Click New => add your path C:\Windows\system32\ngrok.exe => click OK.
  4. Restart your bash and you should be able to run "ngrok http 80" command.
il0v3d0g
  • 655
  • 6
  • 14
  • Can you show an example of what it looks like for Mac? – Roger Perez Nov 26 '19 at 22:00
  • Type "echo $PATH" in your terminal and see what paths comes back.( '/usr/local/bin:/usr/bin:/bin:/usr/sbin:...etc'). If you installed your package locally, chances are it's in user/local/bin or user/bin, so try to see if ngrok is listed there, if so and your $PATH doesn't have those paths listed, modify $PATH in .bash_profile to include them. https://coolestguidesontheplanet.com/add-shell-path-osx/ hope it makes sense.. Mine is in My-MacBook-Pro/usr/local/bin/ngrok https://www.quora.com/Whats-the-difference-between-usr-bin-and-usr-local-bin – il0v3d0g Nov 27 '19 at 23:44
  • Worked for me on windows, thank you – Sebastian Jun 04 '21 at 12:34
  • Windows solution worked for me. than you for the instructions – Qadir Hussain Oct 18 '22 at 12:18
23

I had followed the instructions as per the ngrok download instructions:

enter image description here

So the file downloaded to ~/Downloads

But I still needed to move ngrok into my binaries folder, like so:

mv ~/Downloads/ngrok /usr/local/bin

Then running ngrok in terminal works

stevec
  • 41,291
  • 27
  • 223
  • 311
13

just download it , unzip it run

./ngrok http 80
Keaz
  • 955
  • 1
  • 11
  • 21
  • 1
    This creates a problem if you are using source control, its unlikely you want to commit a copy of ngrok. The answer moving the executable to `/usr/local/bin` is more sustainable in my view. – Vincent Buscarello Feb 18 '19 at 20:08
6

For Linux :https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip

For Mac :https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-darwin-amd64.zip

For Windows:https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-windows-amd64.zip

unzip it for linux and mac users move file to /usr/local/bin and execute ngrok http 80 command in the terminal

I don't have any idea about windows

Devashish
  • 393
  • 6
  • 10
6

On Windows 10, for me

ngrok http 80

Behaves like this:

  • works from Command Prompt (cmd.exe)
  • does not work from Git Bash
  • does not work from Windows PowerShell

To make available in git bash, you can add the following function to your .bashrc file

function ngrok { cmd.exe /c "ngrok $1 $2 $3";}
KyleMit
  • 30,350
  • 66
  • 462
  • 664
IAmBotmaker
  • 322
  • 5
  • 15
5

run sudo npm install ngrok --g a very simple way to install

sudo because you are installing it globally

walid youssef
  • 93
  • 1
  • 9
3

add line in .zshrc

# vi .zshrc

alias ngrok="/usr/local/lib/node_modules/node/lib/node_modules/node/lib/node_modules/ngrok/bin/ngrok"
seunggabi
  • 1,699
  • 12
  • 12
2

For installation in Windows : Download and extract to any directory (lets say c drive)

  • Then double click on the extracted ngrok.exe file and you'll be able to see the command prompt.

  • And just type ngrok http 4040 // here I am exposing [port 4040]

Agilanbu
  • 2,747
  • 2
  • 28
  • 33
Anupam
  • 131
  • 2
  • 6
1

On Windows ngrok.cmd works well from Git Bash, not ngrok

Ruslan G
  • 11
  • 1
1

The only solution that worked for me was

yarn global add ngrok 
yarn global add exp

with npm I was getting permission errors etc..

Juanma Menendez
  • 17,253
  • 7
  • 59
  • 56
1

In my case, I kept ignoring the instructions that very explicitly tell you to use a terminal on Mac OS, because it looked like it was unzipping correctly:

On Linux or Mac OS X you can unzip ngrok from a terminal with the following command. On Windows, just double click ngrok.zip to extract it.

unzip /path/to/ngrok.zip

However, as soon as I tried running the above command in my terminal, it worked perfectly fine!

AnnieP
  • 350
  • 1
  • 6
  • 13
0

Windows:

  1. Extract.
  2. Open folder
  3. Right click Windows Powershell.
  4. ngrock http 5000 {your post number instead of 5000}
  5. Make sure local server is running on another cmd too.

//Do not worry about auth step

user3156040
  • 723
  • 5
  • 5
0

Ngrok can be installed with Yarn , then you can run by power Sheel. it's was the only way that worked for me in windows 10 . In the begin you need to install the Node : https://nodejs.org/en/. and the yarn: https://nodejs.org/en/.

0

You can use Snap for downloading ngrok. Follow the steps below:

  1. Install Snap by following command:

    sudo apt install snapd
    
  2. Install Ngrok by following command:

    sudo snap install ngrok
    
  3. Now use ngrok command from any directory, like this:

    ngrok http 8080
    
Farid Chowdhury
  • 2,766
  • 1
  • 26
  • 21
0

In case anyone else runs into this with git bash, after install, I was able go to get it to work by adding the path to the exe to my .bashrc file like:

$ export PATH=$PATH:"/c/<path to containing folder>/ngrok"

After saving and opening a new shell, running 'ngrok --help' was successful

KrazyK786
  • 9
  • 1
-1

In shorts,ngrok should be in same directory in which you are running ngrok command.