No, vnstat does not copy its configuration into the database or read the config file only once at first launch. The daemon and the command-line tools parse /etc/vnstat.conf fresh every time a vnstat process starts. If your edits seem to be ignored, the usual culprit is that the lines you changed still begin with a semicolon. In vnstat's config format, both # and ; start a comment, so ;UseLogging 1 is not a setting at all — it is skipped entirely, and the compiled-in default (UseLogging 2, syslog) remains in effect.
Both # and ; start comments in vnstat.conf
The example configuration that ships with vnstat lists nearly every setting commented out with a leading semicolon. This is deliberate: the file doubles as documentation, and the parser skips anything starting with # or ;. The lines you see in vnstat --showconfig such as ;UseLogging 2, ;CreateDirs 1, and ;UpdateFileOwner 1 are not "active values" — they are the built-in defaults shown for reference.
So when the file was edited to change 2 to 1 and point LogFile at a custom directory, but the semicolon was left in place, the parser saw two comment lines and nothing else. The result looks exactly like vnstat refuses to re-read the file, even though it reads it faithfully every time. A related trap: a setting and a comment cannot share a line. Put remarks on their own line above the setting, and leave the value alone at the end of its line.
What the database stores (and why deleting it will not help)
The vnstat database holds only traffic counters and per-interface history — daily and monthly totals, not configuration. There is no cached copy of vnstat.conf inside it, and deleting it would simply destroy your accumulated statistics without changing a single setting.
The actual lifecycle is simple:
- The daemon (
vnstatd) reads the config once, when it starts. Changes require a restart. - CLI commands such as
vnstatread the config on every invocation, so output-related settings take effect immediately. vnstat --showconfigprints the file as the parser sees it, including commented lines — which is why the untouched defaults kept showing up.
Fixing the config and confirming the change
Turn the two lines into plain, uncommented settings:
UseLogging 1
LogFile "/home/me/logs/vnstat/vnstat.log"
Then verify what the parser now sees:
vnstat --showconfig | grep -iE 'uselogging|logfile'
You want lines without a leading ; showing your new values. Finally, restart the daemon so it picks up the daemon-side settings:
sudo systemctl restart vnstat
Confirm the daemon came up cleanly and is logging where you expect:
journalctl -u vnstat -n 20 --no-pager
The catch with logging under /home
Even with the syntax fixed, a log path under /home will likely fail on its own. The packaged service runs as the dedicated vnstat user and, on most distributions, the unit enables ProtectHome=true, so the daemon cannot read or write anything under /home at all.
You have two options:
- Recommended: keep the log at
/var/log/vnstat/vnstat.log. With the defaultCreateDirs 1, the daemon creates the directory itself, and no systemd changes are needed. - Override the sandbox: run
sudo systemctl edit vnstatand add a section that relaxes the restriction, then create the directory and hand it to thevnstatuser:
[Service]
ProtectHome=false
sudo mkdir -p /home/me/logs/vnstat
sudo chown vnstat:vnstat /home/me/logs/vnstat
The override works, but it weakens the service's isolation. Unless you specifically need the log in your home directory, the /var/log location is the lower-friction choice.
Checklist for future config edits
- Remove the leading
;from every line you intend to activate. - Keep one setting per line, with no trailing comment text.
- Check your work with
vnstat --showconfigbefore restarting anything. - Restart the daemon with
sudo systemctl restart vnstatfor daemon-side keys like logging. - Make sure the target paths are writable by the
vnstatuser and reachable given the unit's sandboxing options.
Frequently Asked Questions
Does vnstat store its configuration in the database?
No. The database contains only traffic data and interface metadata. All settings come from the config file, parsed by each vnstat process at startup.
How often is the configuration read?
Every process start. Command-line invocations re-read it each time, so client-side options apply immediately; the daemon only re-reads it when restarted.
Can I put a comment on the same line as a setting?
No. Anything after # or a leading ; is comment material, and a value must end its own line. Put comments on separate lines.
Can I keep the log file under /home?
Only by overriding ProtectHome in the systemd unit and giving the vnstat user a writable directory there. Logging to /var/log/vnstat avoids the problem entirely.
Can I point vnstat at a different config file?
Yes. Both the CLI tools and vnstatd accept a --config option with a path to an alternative file, which is handy for testing changes before editing the system-wide config.
Will deleting the database force a config reload?
No. It only erases your traffic history. Fix the comment characters in the config and restart the daemon instead.