{"record":{"id":"d80be8fa2e350bf8","repo":"vectordotdev/vector","slug":"failed-to-set-socket-permissions","errorCode":null,"errorMessage":"Failed to set socket permissions","messagePattern":"Failed to set socket permissions","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/sources/util/unix_datagram.rs","lineNumber":46,"sourceCode":"/// Returns a `Source` object corresponding to a Unix domain datagram socket.\n/// Passing in different functions for `decoder` and `handle_events` can allow\n/// for different source-specific logic (such as decoding syslog messages in the\n/// syslog source).\npub fn build_unix_datagram_source(\n    listen_path: PathBuf,\n    socket_file_mode: Option<u32>,\n    max_length: usize,\n    decoder: Decoder,\n    handle_events: impl Fn(&mut [Event], Option<Bytes>) + Clone + Send + Sync + 'static,\n    shutdown: ShutdownSignal,\n    out: SourceSender,\n) -> crate::Result<Source> {\n    Ok(Box::pin(async move {\n        let socket = UnixDatagram::bind(&listen_path).expect(\"Failed to bind to datagram socket\");\n        info!(message = \"Listening.\", path = ?listen_path, r#type = \"unix_datagram\");\n\n        change_socket_permissions(&listen_path, socket_file_mode)\n            .expect(\"Failed to set socket permissions\");\n\n        let result = listen(socket, max_length, decoder, shutdown, handle_events, out).await;\n\n        // Delete socket file.\n        if let Err(error) = remove_file(&listen_path) {\n            emit!(UnixSocketFileDeleteError {\n                path: &listen_path,\n                error\n            });\n        }\n\n        result\n    }))\n}\n\nasync fn listen(\n    socket: UnixDatagram,\n    max_length: usize,","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/src/sources/util/unix_datagram.rs#L28-L64","documentation":"After successfully binding the Unix datagram socket, the source applies the configured socket_file_mode via change_socket_permissions and .expect()s success. Failure panics with \"Failed to set socket permissions\", meaning chmod on the socket file failed, usually due to filesystem permissions or an unsupported filesystem.","triggerScenarios":"The socket file lives on a filesystem that does not support permission changes or the Vector process lacks ownership of the socket path (e.g. socket created in a root-owned directory); socket_file_mode configured to an invalid mode value.","commonSituations":"Non-root Vector writing to /var/run with restrictive umask; container volumes mounted with restrictive options; NFS or tmpfs oddities; misconfigured socket_file_mode in the source config.","solutions":["Run Vector as a user that owns the socket file's directory, or pre-create the directory with correct ownership","Set a valid socket_file_mode in the source config (e.g. 0o666) or remove it to use defaults","Move the socket path to a local filesystem (not NFS) that supports chmod","Grant write/ownership rights on the parent directory instead of loosening global permissions"],"exampleFix":"// before\nchown root:root /var/run/vector-sock\n// after\nchown vector:vector /var/run/vector-sock && chmod 770 /var/run/vector-sock","handlingStrategy":"validation","validationCode":"install -d -o vector -g vector /var/run/vector && echo dir-ready","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-create the socket directory with correct ownership before Vector starts","Run Vector under a user that owns the socket path","Keep socket paths on local filesystems that support chmod"],"tags":["rust","panic","permissions","unix-socket"],"backgroundTag":"file-write-permission-denied","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"}