I'm connecting using VPNBook servers and it works fine with this command:

 sudo openvpn --config /etc/openvpn/vpnbook-udp-53.ovpn --auth-user-pass /etc/openvpn/password.txt

but I just can't seem to figure out how to stop it without a reboot.

I've tried service openvpn stop and /etc/init.d/vpnbook stop, but that doesn't seem to affect it.

  • How exactly with ifconfig? – Adam May 23 '13 at 13:59
  • Which one would it be? eth0, lo, tun2, or wlan0 – Adam May 23 '13 at 14:13
  • simply do > sudo /etc/init.d/network-manager restart < – Qasim May 23 '13 at 15:06
  • I am curious, when a VPN is started this way does it not show up in the network manager. I have only always used the network manager connect and disconnect and don't currently have a VPN to test but wondered. – Dennis Feb 19 '14 at 12:49

This command definitely works for me, and it should work for you too.

sudo killall openvpn
| improve this answer | |
  • Might require sudo apt-get install psmisc on some builds – geotheory Oct 29 '15 at 22:51
  • I had to kill -9 it on Ubuntu 16.04 (yes I know...) – Gregor Apr 5 '19 at 8:09
  • this just kills every openvpn process. I have several and want to close just some. Is there a better way? – johannes_lalala Jan 23 at 12:44

The successful steps in my case were:

# stop the service    
$ sudo /etc/init.d/openvpn stop

# find the process if for some reason it keeps running
$ lsof -i | grep openvpn

# kill the proccess(s) by its PID
$ kill -9 <PID>

# if necessary restart the service again
$ sudo /etc/init.d/openvpn start

For some reason killall -SIGIN openvpn did not work for me, but the steps above did.

| improve this answer | |
  • Well, this is the best answer in my opinion. Killing process is the weird method, but requesting the service to stop should do things as it must. – Sopalajo de Arrierez Jul 27 '15 at 22:21
  • In general, you shouldn't "kill -9" things until you've tried an interrupt or otherwise cleanly existing it first. Programs can catch an interrupt and do cleanup, but can't catch signal nine (term). Particularly in the case of openvpn, killing it with -9 does not allow the post scripts to run, and very likely will leave now-invalid routes laying around. Ideally, you'd kill -SIGINT, then wait a few seconds for the pid to end, and only go with -SIGTERM / -9 if it didn't exit before that. – dannysauer Aug 16 '18 at 19:44
  • Just for reference: "9" ist SIGKILL and "15" is SIGTERM - see kill -L – Gerd Jan 23 at 11:10
  • how do I selectively close certain vpn connections? – johannes_lalala Jan 23 at 12:45

Try this

killall -SIGINT openvpn

You can get more info on different signals you can send here: http://openvpn.net/index.php/open-source/documentation/howto.html#control

| improve this answer | |
  • killall -SIGINT openvpn openvpn(15360): Operation not permitted openvpn: no process found sudo killall -SICINT openvpn SICINT: unknown signal; killall -l lists signals. – Adam May 23 '13 at 13:57
  • 1
    sudo killall openvpn in a new terminal worked for me. – Adam May 24 '13 at 18:09
  • @Adam: it's SIGINT, not SICINT – Dzamo Norton Jul 24 '17 at 10:23
  • The kill and killall commands send SIGTERM by default, which the documentation says has the same effect as SIGINT. So, either would work equivalently - if spelled properly. ;) – dannysauer Aug 16 '18 at 19:47

Just hit CTRL+C in the terminal you just started OpenVPN.

| improve this answer | |
  • 2
    What if it was started w/the -daemon (background) flag? It's not possible in this case. – mr-sk Sep 25 '15 at 22:40
  • 1
    Also this leaves 'tun0' as an interface, so it's not possible to restart without rebooting or doing some system config file editing while running. – Dennis Oct 17 '15 at 0:04
  • 1
    What if teh terminal was closed accidentally. ? – varun Apr 21 '16 at 11:43
  • 1
    @Dennis ifconfig tun0 down helps in this case. – gnysek Sep 20 '18 at 16:04

In case sudo killall openvpn does not finish the job (I experienced it a few times) then a sharp and fatal solution would be:

pgrep openvpn | xargs sudo kill -9
| improve this answer | |
  • sudo pkill openvpn whould do the job as well. – ShahinSorkh May 8 at 6:53

after running sudo killall openvpn or service openvpn stop the virtual interface "tun0" would remain opened and referenced in route table, so actually related connections would be lost since openvpn service is killed.

the solution is to delete this virtual connection after killing openvpn service, as it is created everytime when openvpn service gets connected.

so you need to run below commands for disconnecting openvpn:

$ sudo killall openvpn
$ sudo ip link delete tun0
| improve this answer | |

Use the following command, where 0 is the tunnel number:

sudo ifconfig tun0 down
| improve this answer | |

sudo update-rc.d openvpn disable

Or edit the config file in /etc/default/openvpn

sudo nano /etc/default/openvpn

And uncomment the line:


So it looks like:


Then you'll have to run:

sudo service openvpn start < vpn-name > to manually start the VPN.

sudo service openvpn stop < vpn-name > to manually stop the VPN.

< vpn-name > is the config file name without .conf extension

located in /etc/openvpn and without the < >

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.