I started a VPN connection with sudo openvpn --daemon --config connection.ovpn. Is there a way to terminate this connection without using ps to search for the process and then kill it myself?

4 Answers 4


Since OpenVPN does not seem to offer any function of its own for this, you are probably looking for pkill <process-name>, which will search for all processes matching the given name, and kill them.

If you got multiple instances running, but would like to kill only a specific one, the -f option allows you to match against the full process-call including parameters, e.g. pkill -f "openvpn --config connection.ovpn".

See the output from ps x or pgrep -lf <process-name> (same as pkill, but doesn't kill them, so essentially similar to ps | grep <name>) to find out with which parameters the daemon was started.


From https://openvpn.net/community-resources/how-to/

Controlling a running OpenVPN processRunning on Linux/BSD/Unix

OpenVPN accepts several signals:

SIGUSR1 — Conditional restart, designed to restart without root privileges
SIGHUP — Hard restart
SIGUSR2 — Output connection statistics to log file or syslog

Use the writepid directive to write the OpenVPN daemon’s PID to a file, so that you know where to send the signal (if you are starting openvpn with an initscript, the script may already be passing a –writepid directive on the openvpn command line).

So , you should use kill command, and start openvpn with arg -writepid.


No, you will need to kill the process. In fairness a daemon management script would do just that. You can use pgrep or pkill to make your life easier.

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

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

You must log in to answer this question.

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