vnstat - Error: Interface "eth0" not available, exiting.

I recently came across this error message on one of my virtual private servers, where I was trying to have a closer look at the traffic. vnstat is a really cool tool for that sort of thing and on most Linux servers you should be able to install it with sudo apt-get install vnstat.

I was running vnstat -l and got the following response:

getting traffic...Error: Unable to get interface "eth0" statistics.
Error: Interface "eth0" not available, exiting.

The solution to that is to simply specify the right interface while running the command that throws this error message.

To figure out which of your network interfaces is the correct one on a Linux VPS run: vnstat --iflist, which should give you a list of interfaces:

Available interfaces: lo venet0
  • lo is the loopback interface
  • venet0 is the virtual network interfaces name that we need

So running commands specifying that we want to track the traffic of said interface would simply look like: vnstat -i venet0 -l.

changing the vnstat default interface


To permanently change the standard network interface for vnstat, you can edit /etc/vnstat.conf


# vnStat 1.11 config file

# default interface
Interface "eth0"


# vnStat 1.11 config file

# default interface
Interface "venet0"

If you want to have a look at more config options, feel free to check the vnstat conf documentation.

Tagged with: #Linux #vnstat

Thank you for reading! If you have any comments, additions or questions, please tweet or toot them at me!