OpenVPN: An error has occured whilst trying to connect to OpenVPN

Hey guys

I am following this guide
I am stuck on step 12. It tells me that I should be able to connect to OpenVPN right away but I can’t. It gives the aforementioned error.

An error has occurred whilst trying to connect OpenVPN
Unable to connect to OpenVPN management interface

Can anyone help? I’m soooooo close to having this up and working!

Edit: So it appears that OpenVPN opens via sudo in putty and I can connect by typing out this in putty

sudo openvpn /home/osmc/vpn-config/CAToronto.ovpn

Only problem is once I close putty (from my windows laptop) it disconnects OpenVPN.

Now, can I set it to automatically load when OSMC boots up or am I stuck with having to leave putty running 24/7 on my laptop?

So I’ve setup OpenVPN successfully about 5 times now on various RaspBMC and OSMC installs, and each time I’ve found the best guide to use is this one here:

Except rather than edit the ovpn files externally, I prefer to do them on the device. Have a look at the post by jFive here:

So basically you would log into the pi, make sure you’re in your home folder, and do:

sudo wget --no-check-certificate


sudo apt-get install unzip
sudo unzip -d /etc/openvpn/

Personally I find it best to keep everything in /etc/openvpn, just means for me it keeps things simple and openvpn can locate everything it needs. You then need to remove all the spaces from the .ovpn files. Make sure you’re in /etc/openvpn and then for example do:

sudo mv UK\ London.ovpn UKLondon.ovpn
sudo mv US\ New\ York.ovpn USNewYork.ovpn

That will take quite a while but it’s worth it in the long run.

When you’ve done that you can configure them just like jFive has done, putting in ‘/etc/openvpn’ in the three places he’s listed (and /login.conf in the middle line). Don’t forget also to make your ‘login.conf’ file:

sudo nano login.conf

And then follow the other guide in the first link to setup Brian Hornsby’s ui add-on. Doing all this, you won’t ever need Putty in the future, you can activate and deactivate openVPN by use of your TV remote control.

By the way, I’d imagine closing putty is probably killing an open foreground process which is probably why OpenVPN is disconnecting.

Don’t forget also to ‘sudo chmod 400 login.conf’.

Also you may want to look at my thread on how to defeat DNS leaks:

If you do that, in order to edit all the ovpn files in one go, I’ve found the following command useful. Change to your /etc/openvpn directory and type

sudo sh -c 'for filename in *.ovpn; do  echo "script-security 2\nup /etc/openvpn/update-resolv-conf\ndown /etc/openvpn/update-resolv-conf" >> $filename; done'

Don’t forget to edit your /etc/openvpn/update-resolve-conf file and add the two lines shown in the last post in that thread, that way when you disconnect OpenVPN your DNS will go back to your default setting.

Okay so first, sudo mv UK\ London.ovpn UKLondon.ovpn.

mv: cannot stat ‘UK London.ovpn’: No such file or directory.

That doesn’t work.

Also OpenVPN just disconnected itself and won’t reconnect for seemingly no reason. I say no reason as in I didn’t touch anything. Just dropped connection and now it will not reconnect at all. So I’m stuck without a working VPN when I didn’t do anything to change it.

Also could you elaborate on the last part?

“By the way, I’d imagine closing putty is probably killing an open foreground process which is probably why OpenVPN is disconnecting.”

Are you saying I have to constantly keep putty running?

Basically long story short, how can I keep my VPN running without having to check it constantly to make sure it didn’t disconnect?

2 posts were split to a new topic: OpenVPN: An error has occurred whilst trying to connect