zed-industries/zed · critical

WSAStartup failed: {}

Error message

WSAStartup failed: {}

What it means

On Windows, the net crate initializes Winsock once with WSAStartup(0x0202) before creating sockets (including AF_UNIX ones). If WSAStartup returns a non-zero error, the process panics on first network use. Winsock startup failures are almost always system-level problems - a corrupted Winsock catalog, resource exhaustion, or a damaged Windows image - not application bugs.

Source

Thrown at crates/net/src/util.rs:18

use std::{
    io::{Error, ErrorKind, Result},
    path::Path,
    sync::Once,
};

use windows::Win32::Networking::WinSock::{
    ADDRESS_FAMILY, AF_UNIX, SOCKADDR_UN, SOCKET_ERROR, WSAGetLastError, WSAStartup,
};

pub(crate) fn init() {
    static ONCE: Once = Once::new();

    ONCE.call_once(|| unsafe {
        let mut wsa_data = std::mem::zeroed();
        let result = WSAStartup(0x202, &mut wsa_data);
        if result != 0 {
            panic!("WSAStartup failed: {}", result);
        }
    });
}

// https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/
pub(crate) fn sockaddr_un<P: AsRef<Path>>(path: P) -> Result<(SOCKADDR_UN, usize)> {
    let mut addr = SOCKADDR_UN::default();
    addr.sun_family = ADDRESS_FAMILY(AF_UNIX);

    let bytes = path
        .as_ref()
        .to_str()
        .map(|s| s.as_bytes())
        .ok_or(ErrorKind::InvalidInput)?;

    if bytes.contains(&0) {
        return Err(Error::new(
            ErrorKind::InvalidInput,

View on GitHub (pinned to f4178619ac)

Solutions

  1. Run 'netsh winsock reset' as administrator and reboot - this rebuilds the catalog and fixes the most common cause
  2. Uninstall or update recently added VPN/antivirus/network-filter software that hooks Winsock
  3. Verify basic networking works system-wide (other apps, a tiny socket test program)
  4. If it persists, run sfc /scannow and repair the Windows image, then retry
Defensive patterns

Strategy: retry

Prevention

When it happens

Trigger: The first call into net::util::init() (any socket creation in the crate) on Windows when WSAStartup fails: a corrupt Winsock service-provider catalog (LSP damage from VPN/antivirus/firewall filter drivers), system resource exhaustion, or a broken system image.

Common situations: After installing or removing VPN, antivirus, or network-filter software that hooked Winsock and left the catalog damaged; heavily loaded machines; installations where other networking apps also fail with WSA errors.

Related errors


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/6a1fc90682cbf2a4. Report an issue: GitHub.