vectordotdev/vector · critical

Failed to bind to datagram socket

Error message

Failed to bind to datagram socket

What it means

The Unix datagram source binds a UnixDatagram socket to the configured `path` inside the spawned source task and .expect()s success. If the bind fails, the process panics with "Failed to bind to datagram socket" — typically because the path is unusable: another socket exists, the directory is missing, or permissions deny creation.

Solutions

  1. Remove any stale socket file at the configured path before starting Vector
  2. Ensure the parent directory exists and Vector's user has write permission
  3. Stop the other process (or previous Vector instance) already bound to that path
  4. Change the configured socket path to a writable, shorter location

Example fix

// before
rm: not done; /var/run/vector.sock is stale
// after
rm -f /var/run/vector.sock && vector --config vector.yaml
Defensive patterns

Strategy: validation

Validate before calling

SOCK=/var/run/vector.sock; rm -f "$SOCK"; test -d "$(dirname "$SOCK")" && test -w "$(dirname "$SOCK")" && echo ok

Prevention

When it happens

Trigger: path points to a directory that does not exist or is not writable; a stale socket file from a previous unclean shutdown occupies the path; another Vector instance is already bound; the path exceeds unix socket path length limits.

Common situations: Restarting Vector after SIGKILL leaves the socket file behind; container filesystems with read-only paths; running as non-root while path is in /var/run; duplicated configs binding the same socket path.

Related errors


AI-assisted analysis of vectordotdev/vector@bdb87aeaa4 (2026-09-16). Data as JSON: /api/errors/bfd7e7749310680d. Report an issue: GitHub.

Appendix: source

Thrown at src/sources/util/unix_datagram.rs:42

        util::{change_socket_permissions, unix::UNNAMED_SOCKET_HOST},
    },
};

/// Returns a `Source` object corresponding to a Unix domain datagram socket.
/// Passing in different functions for `decoder` and `handle_events` can allow
/// for different source-specific logic (such as decoding syslog messages in the
/// syslog source).
pub fn build_unix_datagram_source(
    listen_path: PathBuf,
    socket_file_mode: Option<u32>,
    max_length: usize,
    decoder: Decoder,
    handle_events: impl Fn(&mut [Event], Option<Bytes>) + Clone + Send + Sync + 'static,
    shutdown: ShutdownSignal,
    out: SourceSender,
) -> crate::Result<Source> {
    Ok(Box::pin(async move {
        let socket = UnixDatagram::bind(&listen_path).expect("Failed to bind to datagram socket");
        info!(message = "Listening.", path = ?listen_path, r#type = "unix_datagram");

        change_socket_permissions(&listen_path, socket_file_mode)
            .expect("Failed to set socket permissions");

        let result = listen(socket, max_length, decoder, shutdown, handle_events, out).await;

        // Delete socket file.
        if let Err(error) = remove_file(&listen_path) {
            emit!(UnixSocketFileDeleteError {
                path: &listen_path,
                error
            });
        }

        result
    }))
}

View on GitHub (pinned to bdb87aeaa4)