rustdesk/rustdesk · error

Failed to read --server process uid

Error message

Failed to read --server process uid

What it means

While enumerating `--server` processes to find their uids, a process's user id could not be read (process.user_id() returned None). The code intentionally fails rather than silently skipping, because an unmatched key process would break stable uid-based target selection for root CLI commands.

Source

Thrown at src/ipc.rs:1399

    let mut server_uids = Vec::new();
    for process in sys.processes().values() {
        if process.pid() == current_pid {
            continue;
        }
        if process.cmd().get(1).map_or(true, |arg| arg != "--server") {
            continue;
        }
        let Ok(process_path) = std::fs::canonicalize(process.exe()) else {
            continue;
        };
        if process_path != current_exe_path {
            continue;
        }
        let Some(uid) = process.user_id().map(|uid| **uid as u32) else {
            // Root CLI management commands need a stable matching `--server` target.
            // If this key process races during enumeration, failing the command is clearer
            // than silently skipping it; `--server` is not expected to exit frequently.
            bail!("Failed to read --server process uid");
        };
        server_uids.push(uid);
    }
    Ok(server_uids)
}

#[cfg(any(target_os = "linux", target_os = "macos"))]
fn user_main_ipc_server_uid() -> ResultType<u32> {
    let server_uids = running_server_uids_for_current_exe()?;
    #[cfg(target_os = "linux")]
    let prefer_root = crate::platform::linux::is_login_screen_wayland();
    #[cfg(target_os = "macos")]
    let prefer_root = false;
    select_server_uid_for_user_main_ipc(&server_uids, active_uid(), prefer_root)
}

pub async fn connect(ms_timeout: u64, postfix: &str) -> ResultType<ConnectionTmpl<ConnClient>> {
    #[cfg(any(target_os = "linux", target_os = "macos"))]

View on GitHub (pinned to 91c9fccbb0)

Solutions

  1. Rerun the command — the race is transient
  2. Check /proc permissions (hidepid mount option) if it reproduces
  3. Ensure the RustDesk service is not being restarted concurrently
  4. Run the enumeration with sufficient privileges to read process uids

Example fix

// before
let uids = running_server_uids_for_current_exe()?;
// after
let uids = match running_server_uids_for_current_exe() {
    Ok(u) => u,
    Err(e) if e.to_string().contains("Failed to read --server process uid") => {
        std::thread::sleep(std::time::Duration::from_millis(200));
        running_server_uids_for_current_exe()?
    }
    Err(e) => return Err(e),
};
Defensive patterns

Strategy: retry

Try / catch

match running_server_uids_for_current_exe() {
    Ok(u) => u,
    Err(e) if e.to_string().contains("uid") => {
        std::thread::sleep(Duration::from_millis(200));
        running_server_uids_for_current_exe()?
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: A `--server` process matched by exe path disappears or its metadata becomes unreadable mid-enumeration (race with process exit), or the OS denies uid access for that process.

Common situations: Service being restarted exactly while a management command runs; restricted /proc permissions in hardened environments (hidepid) or containers limiting process metadata access.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of rustdesk/rustdesk@91c9fccbb0 (2026-09-10). Data as JSON: /api/errors/945817267300354f. Report an issue: GitHub.