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, 2013 at 13:59
  • Which one would it be? eth0, lo, tun2, or wlan0
    – Adam
    May 23, 2013 at 14:13
  • simply do > sudo /etc/init.d/network-manager restart <
    – Qasim
    May 23, 2013 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, 2014 at 12:49

17 Answers 17


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

sudo killall openvpn
  • 1
    Might require sudo apt-get install psmisc on some builds
    – geotheory
    Oct 29, 2015 at 22:51
  • I had to kill -9 it on Ubuntu 16.04 (yes I know...)
    – Gregor
    Apr 5, 2019 at 8:09
  • 1
    this just kills every openvpn process. I have several and want to close just some. Is there a better way? Jan 23, 2020 at 12:44
  • 2
    @johannes_lalala, you probably already figured this out, but this worked on my side: openvpn3 session-manage --config "$CONFIGURATION_PROFILE_NAME" --disconnect Hopefully that will help someone out. BTW, I got the command from this wiki page: community.openvpn.net/openvpn/wiki/OpenVPN3Linux
    – Spencer D
    Dec 14, 2020 at 5:13
  • @SpencerD I tried it and got If 'openvpn3' is not a typo you can use command-not-found to lookup the package that contains it, like this: cnf openvpn3. I also tried openvpn session-manage --config "$CONFIGURATION_PROFILE_NAME" --disconnect (without the 3) instead, but the parameters seem not fitting: Options error: I'm trying to parse "session-manage" as an --option parameter but I don't see a leading '--' Use --help for more information.
    – Cadoiz
    Mar 7 at 12:04

I had same problem with disconnecting from openvpn3

I end up creating this small repo that helps manage the openvpn3 sessions

To disconnect the session, you have know the session's Path

openvpn3 session-manage --session-path $OPENVPN3_SESSION_PATH --disconnect

the session path could be found via

openvpn3 sessions-list

> -----------------------------------------------------------------------------
>         Path: /net/openvpn/v3/sessions/7a42f37asc8d9s424c8b534sd331d6dd56e8
>      Created: Tue Dec  8 10:44:57 2020                  PID: 9495
>        Owner: shmalex                                Device: tun0
>  Config name: client.ovpn  (Config not available)
> Session name: ***.***.***.***
>       Status: Connection, Client connected
> -----------------------------------------------------------------------------
openvpn3 session-manage --session-path $OPENVPN3_SESSION_PATH --disconnect

You can use my repo to perform same actions with help of bash files.

  • 4
    This is THE CORRECT answer, and should be the accepted one too. I get, however, why the answers with kill command are so upvoted, I wouldn't blame them or the voters, I wish the disconnect command was really practically 'a' command.
    – 0xc0de
    Jul 27, 2021 at 10:28
  • 1
    This is indeed the correct answer, and thanks for writing those bash files - makes life much easier!
    – jonsedar
    Nov 17, 2021 at 10:27

The successful steps in my case were:

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

# find the process if it is still running for some reason
$ 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 -SIGINT openvpn did not work for me, but the steps above did.
  • 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. Jul 27, 2015 at 22:21
  • 1
    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, 2018 at 19:44
  • Just for reference: "9" ist SIGKILL and "15" is SIGTERM - see kill -L
    – Gerd
    Jan 23, 2020 at 11:10
  • how do I selectively close certain vpn connections? Jan 23, 2020 at 12:45
  • not tested, but you can use kill -9 $(pidof <processname>)
    – funder7
    Mar 31 at 14:31

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
  • 3
    sudo pkill openvpn whould do the job as well. May 8, 2020 at 6:53

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

  • 2
    What if it was started w/the -daemon (background) flag? It's not possible in this case.
    – mr-sk
    Sep 25, 2015 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, 2015 at 0:04
  • 1
    What if teh terminal was closed accidentally. ?
    – varun
    Apr 21, 2016 at 11:43
  • 1
    @Dennis ifconfig tun0 down helps in this case.
    – gnysek
    Sep 20, 2018 at 16:04

I stumbled upon having 2 open sessions with the same config path. So I could not use

openvpn3 session-manage --disconect --config <config_path>

session-manage: ** ERROR ** More than one session with the given configuration profile name was found.

So I made a script to loop through sessions (session ids are not always the same as the config paths)

ACTIVE_SESSIONS=$(openvpn3 sessions-list | grep -i 'path' | awk '{p=index($0, ":");print $2}')
for instance in $ACTIVE_SESSIONS; do
    openvpn3 session-manage --disconnect --session-path ${instance}
  • Well, this is nice! I've integrated the first command as External tool into phpstorm. Btw I would have used the script if I had more active sessions! I'll keep it, just in case .. Nice work! :-)
    – funder7
    Mar 31 at 14:55

Try this

killall -SIGINT openvpn

You can get more info on the different signals you can send here.

  • 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, 2013 at 13:57
  • 1
    sudo killall openvpn in a new terminal worked for me.
    – Adam
    May 24, 2013 at 18:09
  • @Adam: it's SIGINT, not SICINT Jul 24, 2017 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, 2018 at 19:47

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

sudo openvpn3 session-manage --disconnect --config $'client'.ovpn

Replace client with the corresponding name.
This will shutdown the session.


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

sudo ifconfig tun0 down

Use the following command:

   $openvpn3 session-manage --session-path /net/openvpn/v3/sessions/..... --disconnect

you may get the path using command below:

openvpn3 sessions-list

You can use the following script to disconnect all vpn sessions or a specific vpn session

vpnd.sh [session path]


set -e


if [ "$1" = "--help" ]; then
    echo "Usage : ./vpnd.sh [session path]"
    echo "E.g. disconnect specific session"
    echo "vpnd.sh /net/openvpn/v3/sessions/b7a35c15s95ffs4cd9sa867sc473a37d77a0"
    echo "E.g. disconnect all sessions"
    echo "vpnd.sh"
    exit 1

if [ ! -z "$session" ]; then
    openvpn3 session-manage --disconnect --session-path "${session}"
    exit 0

readarray -t vpn_sessions < <(openvpn3 sessions-list | sed -nE 's/^\s*Path:\s+(\S*)$/\1/p')
for session in ${vpn_sessions[@]} ; do  
    if [ ! -z "${session}" ]; then
        echo "Closing session ${session}..."
        openvpn3 session-manage --disconnect --session-path "${session}"

openvpn3 session-manage --cleanup
openvpn3 sessions-list

Note that you can get a list of active session paths via

openvpn3 sessions-list


Quick one-liner:

sudo openvpn3 sessions-list | grep -ioP '/net/openvpn/v3/sessions/\w+' | xargs -I{} sudo openvpn3 session-manage --path {} --disconnect

openvpn3 sessions-list

It will print a PID number

sudo kill -9 {PID} without the curly braces of course.


For me works this:

your@prompt: openvpn3 session-manage --disconnect --path </PATH/PROVIDED/IN/SESSION/START>

This worked for me.

When you login to ovpn. It will give a session file with full path. Put that full path after --session-path in below command

openvpn3 session-manage --session-path /net/openvpn/v3/sessions/<session file> --disconnect
New contributor
Prajna is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
sudo update-rc.d openvpn disable

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

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.

Where <vpn-name> is the config file name located in /etc/openvpn without the .conf extension and without the < >

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.