{"record":{"id":"b3305dbc5441aa01","repo":"vectordotdev/vector","slug":"systemd-fd-already-consumed","errorCode":null,"errorMessage":"systemd fd already consumed","messagePattern":"systemd fd already consumed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/sources/util/net/tcp/mod.rs","lineNumber":71,"sourceCode":"    mut listenfd: ListenFd,\n    tls: &MaybeTlsSettings,\n    tls_reloader: Option<TlsAcceptorReloader>,\n    allowlist: Option<Vec<IpNet>>,\n) -> crate::Result<MaybeTlsListener> {\n    match addr {\n        SocketListenAddr::SocketAddr(addr) => tls\n            .bind_reloadable(&addr, tls_reloader)\n            .await\n            .map_err(Into::into),\n        SocketListenAddr::SystemdFd(offset) => match listenfd.take_tcp_listener(offset)? {\n            Some(listener) => {\n                listener.set_nonblocking(true)?;\n                TcpListener::from_std(listener)\n                    .map(Into::into)\n                    .map_err(Into::into)\n            }\n            None => {\n                Err(io::Error::new(io::ErrorKind::AddrInUse, \"systemd fd already consumed\").into())\n            }\n        },\n    }\n    .map(|listener| listener.with_allowlist(allowlist))\n}\n\n#[derive(Clone, Copy, Eq, PartialEq)]\npub enum TcpSourceAck {\n    Ack,\n    Error,\n    Reject,\n}\n\npub trait TcpSourceAcker {\n    fn build_ack(self, ack: TcpSourceAck) -> Option<Bytes>;\n}\n\npub struct TcpNullAcker;","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/src/sources/util/net/tcp/mod.rs#L53-L89","documentation":"When a TCP source is configured with SocketListenAddr::SystemdFd, Vector obtains the listening socket from systemd socket activation (LISTEN_FDS). try_bind_tcp_listener calls listenfd.take_tcp_listener(offset); if systemd already handed out that fd (or no fd was passed), it returns None and Vector raises io::ErrorKind::AddrInUse with 'systemd fd already consumed'. Each fd can only be taken once per process.","triggerScenarios":"A source uses SocketListenAddr::SystemdFd(offset) and listenfd.take_tcp_listener(offset) returns None — the fd was already consumed by another component in the same process, or Vector was started without systemd socket activation providing the fd.","commonSituations":"Two sources configured with the same systemd fd offset; running Vector manually (not under systemd) with SystemdFd listen addresses; systemd unit missing Sockets= or socket activation not enabled; reusing one systemd socket for multiple Vector sources.","solutions":["Ensure each source uses a unique systemd fd offset and that the systemd socket unit passes enough fds.","Run Vector under systemd with the matching .socket unit (Sockets=, ListenStream=) so LISTEN_FDS is set.","If not using socket activation, replace listen_address SystemFd with a plain SocketAddr.","Check for duplicate source configs referencing the same fd."],"exampleFix":"// before\nsources.in1.listen_address = \"systemd:3\"\nsources.in2.listen_address = \"systemd:3\"  // same fd\n// after\nsources.in1.listen_address = \"systemd:0\"\nsources.in2.listen_address = \"0.0.0.0:6000\"","handlingStrategy":"validation","validationCode":"# Before deploy: verify socket activation\nsystemctl show vector.socket --property=Listen\n# Ensure LISTEN_FDS is set in the Vector unit environment","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use unique systemd fd offsets per source.","Only use systemd:<offset> addresses when actually running under systemd with a paired .socket unit.","Prefer explicit SocketAddr unless socket activation is required."],"tags":["tcp","systemd","socket-activation","address-in-use","source"],"backgroundTag":"address-already-in-use","analyzedSha":"bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013","analyzedAt":"2026-09-16T02:53:35.741Z","contentChangedAt":"2026-09-16T02:53:35.741Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}