#1042377 clamav-daemon does not listen on TCP port

Package:
clamav-daemon
Source:
clamav-daemon
Description:
anti-virus utility for Unix - scanner daemon
Submitter:
Thomas Walter
Date:
2026-07-26 19:03:01 UTC
Severity:
normal
#1042377#5
Date:
2023-07-27 07:55:41 UTC
From:
To:
Dear Maintainer,

I've been trying to get clamav-daemon to listen on a TCP port on
Bookworm.

To do so I did `dpkg-reconfigure clamav-daemon` and selected `TCP` when
asked for the `Socket type`. Everything else was kept default.

Neither `sudo systemctl daemon-reload`, `sudo systemctl restart
clamav-daemon` or a reboot helped.

`clamav.log` reports the following:

```
Thu Jul 27 09:27:50 2023 -> TCP: No tcp AF_INET/AF_INET6 SOCK_STREAM socket received from systemd.
Thu Jul 27 09:27:50 2023 -> LOCAL: Received AF_UNIX SOCK_STREAM socket from systemd.
```

This makes me think the package is missing some configuration for
systemd to be able to listen on a TCP port instead of a local socket.

Since it worked this way on Debian 11 it might also result in problems
when people do dist-upgrades?

Regards,
     Balu
--- data dir ---
total 226988
-rw-r--r-- 1 clamav clamav    291965 Jul 27 09:23 bytecode.cvd
-rw-r--r-- 1 clamav clamav  61649992 Jul 27 09:23 daily.cvd
-rw-r--r-- 1 clamav clamav        69 Jul 27 09:23 freshclam.dat
-rw-r--r-- 1 clamav clamav 170479789 Jul 27 09:23 main.cvd

#1042377#10
Date:
2023-09-16 17:06:48 UTC
From:
To:
Hello,

since v0.99.2 (more specifically commit b68375fd [0]) clamd supports using sockets it gets passed as file descriptors. If it gets passed at least one socket this way, only those are used and all LocalSocket and TCPSocket statements from the config file are ignored. Unfortunately there seems to be no mention of this behaviour anywhere in the docs, I found it only by looking at the source code.

In bullseye [1] the clamav-daemon package only contains a clamav-daemon.service unit-file, in bookworm in addition to the service unit-file it also contains a clamav-daemon.socket unit-file. According to the systemd.service man-page [3] a service process automatically gets passed the sockets from all same-named socket units. Because in bullseye there was no socket unit, clamd didn't get passed any sockets from systemd and the statements from the config file were used. In bookworm clamd always gets passed a local socket from systemd because of the socket unit, and the config statements are ignored.

The workaround/solution I found is to create a drop-in for the socket unit (see below), letting systemd open the tcp socket and pass it to clamd. In fact, the socket unit-file from upstream [4] already contains a commented-out version of this. See the respective man-page [5] for more details about the syntax and e.g. how to bind to a specific ip address. I would also recommend to removed any socket configuration from clamd.conf to avoid confusion.

/etc/systemd/system/clamav-daemon.socket.d/tcp-socket.conf
```
[Socket]
ListenStream=3310
```

Alternatively you can mask the socket unit (and remove the Requires= from the service unit), which bypasses the whole systemd-socket-business and makes clamd behave like in bullseye, opening its own sockets according to its config file.


[0] https://github.com/Cisco-Talos/clamav/commit/b68375fdbb173b7652bf3b58b5e801906f587a25
[1] https://packages.debian.org/bullseye/amd64/clamav-daemon/filelist
[2] https://packages.debian.org/bookworm/amd64/clamav-daemon/filelist
[3] https://www.freedesktop.org/software/systemd/man/systemd.service.html#Sockets=
[4] https://github.com/Cisco-Talos/clamav/blob/clamav-1.0.1/clamd/clamav-daemon.socket.in#L10
[5] https://www.freedesktop.org/software/systemd/man/systemd.socket.html#ListenStream=
--- Greetings Corubba
#1042377#15
Date:
2025-07-23 15:52:25 UTC
From:
To:
Hi,

Thanks for the bug report.

I'm setting up an antivirus scanning server and I couldn't understand why clamav wasn't listening on the TCP socket.

I preferred to leave the TCPSocket option in the clamd configuration file to make it more readable and I mask the "clamav-daemon.socket" unit.

A hint about this behavior in the "/usr/share/doc/clamav-daemon/README.Debian.gz" file would be a plus.

Regards.

#1042377#20
Date:
2026-07-26 18:44:46 UTC
From:
To:
Hi,

I just updated ClamAV from version 1.4.4+dfsg-1 to 1.4.5+dfsg-3, and the
problem seems to be resolved. The systemd generator now appears to
respect the TCPSocket setting:

$ cat  /run/systemd/generator/clamav-daemon.socket.d/listen.conf
# Automatically generated by clamav-daemon-socket-generator
# Based on configuration in /etc/clamav/clamd.conf
[Socket]
# Clear any existing ListenStream directives
ListenStream=
ListenStream=3310

However, for this to work, you need to remove the workaround that was
manually applied earlier.


Regards.