46

I installed openvpn with brew. The installation went fine, no errors or missing dependencies. But now when I try to run it:

users-MBP:~ user$ brew install openvpn
Warning: openvpn-2.3.7 already installed
users-MBP:~ user$ openvpn
-bash: openvpn: command not found

I based myself on this tutorial: https://my.hostvpn.com/knowledgebase/29/OpenVPN-on-Mac-OS-X-via-Homebrew-CLI.html

6
  • Out of curiosity, why did you not choose to go with TunnelBlick? Sep 2, 2015 at 23:28
  • 2
    @agentroadkill After some time on Linux I have a strong preference for command-line tools over GUIs. Whenever possible I try to go for a CLI solution.
    – Juicy
    Sep 2, 2015 at 23:33
  • I believe TunnelBlick is fully configurable from command line, though I rarely use it as I generally use it for simplistic end-user functions. Sep 2, 2015 at 23:36
  • 2
    @agentroadkill I may look into it. openvpn also has the advantage of being the same tool I used on Linux for the job so I could just copy over my configuration files, same commands etc... But I will look into TunnelBlick if I can't get it working.
    – Juicy
    Sep 2, 2015 at 23:44
  • TunnelBlick is just an OpenVPN client for MacOS. Any OpenVPN config generated for Linux and/or Windows can be used with it. Sep 2, 2015 at 23:46

7 Answers 7

27

At the terminal type:

echo $PATH 

That's your default search path for executables. Looks like the openvpn executable was installed someplace not in your search path.

First, you'll need to find the openvpn executable:

sudo find / -type f -name "openvpn" 

Then add the directory containing the openvpn executable to your default search path by adding this sort of line to the end of your .profile (in your home directory, a.k.a. /Users/yourusername/.profile:

export PATH="/some/brew/dir:$PATH"
3
  • 19
    brew info openvpn is faster
    – igor
    Nov 16, 2016 at 23:44
  • Try using sudo openvpn before going with this answer. It seems silly, but I was going through this answer when I found openvpn is installed in the usr/sbin folder - which means that you can't execute openvpn or anything else in that folder without sudo - and you will get openvpn: command not found without using sudo. Or you can login as root, but that's just unnecessary. Hope this helps someone else. Feb 12, 2020 at 22:00
  • Years later, the DMG/PKG installer from openvpn.net/vpn-client no longer seems to contain a command-line client.
    – MarkHu
    May 27, 2021 at 17:13
65

Add this to your ~/.bash_profile:

export PATH=$(brew --prefix openvpn)/sbin:$PATH
3
  • 16
    You won my heart
    – Lo-Tan
    Nov 27, 2017 at 16:23
  • 1
    Works for Apple silicon versions as well. Dec 2, 2021 at 11:48
  • 1
    This worked for me perfectly on 12.6 Intel as well
    – George L
    Dec 6, 2022 at 17:18
16

In my case:

  1. Installation using homebrew

brew install openvpn

  1. Information regarding binaries

brew info openvpn

  1. It gave me installation path as:

/usr/local/Cellar/openvpn/2.4.0

  1. Then I browsed for bin directory but found executable inside sbin. So, I added following line

export PATH=$PATH:/usr/local/Cellar/openvpn/2.4.0/sbin

in my ~/.zshrc file as well as in ~/.bash_profile file using a text editor.

Worked Flawlessly, After a workaround for an hour :)

11

You have to add /usr/local/sbin to your path.

It was installed to /usr/local/sbin but that directory is not in your $PATH by default. Add a line like this to your ~/.bashrc or equivalent:

export PATH=/usr/local/sbin:$PATH
1
  • 1
    This is the best fix, but the best, permanent way to make the fix it is to edit /etc/paths and add /usr/local/sbin to it (more info here)
    – MikeBeaton
    Jan 16, 2019 at 9:34
2

I was having same issue today and I had to do sudo brew services start openvpn

1

You can also add a symlink from usr/local/sbin into usr/local/bin like so:

cd /usr/local/bin
ln -s ../sbin/openvpn .
1

Brew now link the openvpn binary. reinstall it using

brew reinstall openvpn

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .