I'm developing a website for managing OpenVPN users with Django framework. But I need to know is there any way to extract active users from OpenVPN? My server is running Ubuntu 12.04.

9 Answers 9


There should be a status log you can look at to show you, mine is, for examle:

cat /etc/openvpn/openvpn-status.log


As an alternative, adding the flag --management IP port [pw-file] or adding that same directive to your server.conf, for example:

management localhost 7505

This would allow you to telnet to that port and offer you a list of commands to run:

telnet localhost 7505


  • 1
    Thanks but is there any other way not to watch for file changes? For example a library that lists connected users?
    – hamidfzm
    Feb 2, 2014 at 15:18
  • 1
    @HamidFzM not sure about a library, you can use the management interface I added as an edit; please don't use an IP other than localhost as it would surely be a detriment to your security
    – c4urself
    Feb 2, 2014 at 17:05
  • @c4urself, my output for the .log is: bit.ly/1ORnsYp Where can I see the connected users? Is it possible to see the ips assigned to them via this .log? Jul 30, 2015 at 19:21
  • 4
    /etc/openvpn/openvpn-status.log didn't work for me on Debian, it never changed, instead /var/run/openvpn/server.status did worked perfectly.
    – Nelson
    Oct 1, 2017 at 8:20
  • 2
    In Ubuntu 20.04, the path is /var/log/openvpn/openvpn-status.log
    – Peter
    Aug 29, 2020 at 20:55

To complete @sekrett answer :

killall -USR2 openvpn ; tail -f /var/log/syslog

It will keep running, it's not a "regular" kill, just a request to print some stats.

Displayed statistics are very readable. Sample output :

Oct 14 07:34:14 vpn2 openvpn[20959]: Updated,Fri Oct 14 07:34:14 2016
Oct 14 07:34:14 vpn2 openvpn[20959]: Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since
Oct 14 07:26:26 vpn2 openvpn[20959]:,hostname1,213.219.XXX.XXX:63765,Fri Oct 14 07:25:01 2016
Oct 14 07:26:26 vpn2 openvpn[20959]:,hostname2,213.219.XXX.XXX:62416,Sun Sep 25 03:49:19 2016
  • Thanks for improvement. My answer was right but it lacks an example and explanation. :)
    – sekrett
    Dec 6, 2017 at 16:45

I manage our companys OpenVPN servers and the way I see active connections is like this,

add to /etc/openvpn/server.conf

management 5555

restart openvpn server

systemctl restart [email protected]

add an OpenVPN Monitor Python package - this will run via a Gunicorn web server and show active connections,

mkdir /opt/openvpn-monitor

create a virtual env (not required but good practice with py packages)

cd /opt/openvpn-monitor
virtualenv venv
source venv/bin/activate

install required packages

pip install openvpn-monitor gunicorn

add a Monitor config file

vi /opt/openvpn-monitor/openvpn-monitor.conf

datetime_format=%d/%m/%Y %H:%M:%S

name=Your VPN Server Name

start the web server that will show active connections,

gunicorn openvpn-monitor -b --name openvpn-monitor --daemon

To stop monitor

pkill gunicorn 

to see active connections, go to the public IP of your VPN server

http://<ip of openvpn server>

make sure to configure proper firewall for port 80, whitelist only trusted inbound IPs

enter image description here

  • im having some issues with this, i can only connect with not the local lan 192 ip, and at top it says can not connect to localhost:5555 connection refused.
    – Twml
    Feb 19, 2020 at 21:37
  • I had to copy the openvpn-monitor.conf to the folder where openvpn-monitor.py was present. Otherwise it was using its default configuration. The GeoLite2-City.mmdb needs to be downloaded as well from dev.maxmind.com/geoip/geoip2/geolite2 to the folder specified in the configuration file for geoip_data.
    – shr
    Mar 21, 2020 at 6:35
  • @twmi Note that use of in the management directive will restrict the telnet session to originate ON the host running the openvpn service. To open this to other addrs on your LAN, use management 192.168.what.ever 5555. (This is not specific to openvpn, but common to all IP services: opening a listen port on excludes off-host access.)
    – Dan H
    May 25, 2021 at 14:58

I got the same need myself and the easiest solution I found out was to use as mentioned telnet to connect to the management interface(you'll have to add :management localhost 6666, in the server config file) .

To get the exact number of client you can do :

  • telnet localhost 6666
  • status

Then you'll get lot of logs :,test-docker,,Wed May  4 09:37:34 2016,test-docker,,Wed May  4 09:36:59 2016,test-docker,,Wed May  4 09:35:47 2016
Max bcast/mcast queue length,0
  • look for => >CLIENT:ENV,n_clients=19361

In my case since I have a very large number of client, using the log file is definitely not very practical.


You can also send usr2 signal to openvpn process to make it write statistic information to syslog. This is safe, you don't need to reboot in case you did not enable management interface before.

  • can you write a command for this? Jun 28, 2018 at 19:54
  • 1
    @MichaelC wrote it: killall -USR2 openvpn. Then watch the logs. It might be /var/log/syslog or /var/log/messages depending on distro.
    – sekrett
    Jun 29, 2018 at 11:11
  • but it doesn't kill openvpn? Jul 13, 2018 at 15:46
  • 2
    kill command can send different signals, USR2 will not kill, it is just a signal. You can see a list here: linux.org/threads/kill-signals-and-commands-revised.11625 or by running kill -l.
    – sekrett
    Jul 13, 2018 at 16:39
  • 1
    Count is not displayed, you should count the lines yourself. If you have nothing in your logs, check syslog settings.
    – sekrett
    Jul 19, 2018 at 13:07

Just use sacli with the following command. This will list the connected VPN clients.

/usr/local/openvpn_as/scripts/sacli VPNSummary
"n_clients": 15

To see all the IPs use this option. ./sacli VPNStatus

  • 1
    this one is only valid when using OpenVPN Access Server (paid version).
    – apagr
    Jan 24, 2020 at 11:14

I made a litte script that can either do a one time check or be set to keep monitoring with specified intervalls.

I hink this is better than monitoring the /etc/openvpn/openvpn-status.log since this is really slow to update. Maybe there's a way to adjust the intervalls in some settings BUT, I only need to monitor the vpn connections sometimes. Not 24/7. Also its quite a messy log.

This script is on the OpenVPN server. Only tested on Ubuntu 20.04

One time run just do:


To keep monitoring with a 20 second intervall:

./ovpn-activity.sh view 20

Save this to .sh file (example oven-activity.sh):

Make sure to change the VPN subnet to match yours.


SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

# MODIFY this to match your network

####### FUNCTIONS ########

act_check () {
sudo echo "looking for active clients"
#Look for Virtual IPs that are online and save them.
activeIPs=$(fping -ag "$vpn_network")
for ip in $activeIPs; do
        if [[ $i -eq 0 ]]

        echo " -- Active --"
        echo "| "$(sudo grep '/.*Learn: '$ip /var/log/openvpn.log | head -1 | sed 's/\/.*$//')
        echo "| ip: $ip"
        echo " ------------"
        echo " "


if [ "$1" = "view" ] ; then
    echo "view is set"
    if [ -z "$2" ] ; then
        watch "$SCRIPT_DIR""/ovpn-activity"
    watch -n $2  "$SCRIPT_DIR""/ovpn-activity"

exit 0

There is no doubt room for improvements but im not a script genius. I needed it to see when colleagues where using the VPN so that I could see if it was safe to reboot the server. And if so, I could see who was online and call them to ask if it was ok to restart without interrupting their work.

  • In this script is error: $vpn_network="" should be vpn_network=""
    – darkrider
    Sep 7, 2021 at 6:34
  • Wops, my bad. I've updated it now. Dec 7, 2021 at 15:59
sudo tail -f /var/log/openvpn/status.log

In rasbian worked for me.

CTRL c to exit.


Hey @perfecto25 I followed your steps for hosting the OpenVPN monitor, it is working, but now I am curious about adding one more security layer on top of it.

Is there a way to add user authentication to hosted OpenVPN monitor tool on gunicorn, as it contains vulnerable user information?


You must log in to answer this question.

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