tauri-apps/tauri · error

failed to list networks

Error message

failed to list networks

What it means

For mobile dev, the CLI needs the host IP so the device can reach the dev server. local_ip_address::list_afinet_netifas() enumerates network interfaces via the OS getifaddrs-style API; this expect fires when that enumeration itself errors. It is environment-level: the syscall failing is rare and usually tied to sandboxes or an unstable network stack.

Source

Thrown at crates/tauri-cli/src/mobile/mod.rs:185

}

#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct CliOptions {
  pub dev: bool,
  pub features: Vec<String>,
  pub args: Vec<String>,
  pub noise_level: NoiseLevel,
  pub vars: HashMap<String, OsString>,
  pub config: Vec<ConfigValue>,
  pub target_device: Option<TargetDevice>,
}

fn local_ip_address(force: bool) -> &'static IpAddr {
  static LOCAL_IP: OnceLock<IpAddr> = OnceLock::new();
  LOCAL_IP.get_or_init(|| {
    let prompt_for_ip = || {
      let addresses: Vec<IpAddr> = local_ip_address::list_afinet_netifas()
        .expect("failed to list networks")
        .into_iter()
        .map(|(_, ipaddr)| ipaddr)
        .filter(|ipaddr| match ipaddr {
          IpAddr::V4(i) => i != &Ipv4Addr::LOCALHOST,
          IpAddr::V6(i) => i.to_string().ends_with("::2"),

        })
        .collect();
      match addresses.as_slice() {
        [] => panic!("No external IP detected."),
        [ipaddr] => *ipaddr,
        _ => {
          let selected = dialoguer::Select::with_theme(&dialoguer::theme::ColorfulTheme::default())
            .with_prompt(
              "Failed to detect external IP, What IP should we use to access your development server?",
            )
            .items(&addresses)
            .default(0)

View on GitHub (pinned to 52e4b6e71d)

Solutions

  1. Re-run the command once the network stack settles (after VPN/docker changes complete).
  2. Disconnect VPNs / prune unused docker networks so enumeration has a stable interface set.
  3. Move out of restrictive containers/sandboxes for mobile dev runs.
  4. If persistent, capture `ifconfig -a` (or `ip addr`) output and open an issue against the local-ip-address crate usage.
Defensive patterns

Strategy: retry

Try / catch

// Mobile dev wrapper: retry once; interface enumeration failures are transient
for (let i = 0; i < 2; i++) {
  const r = spawnSync("npx", ["tauri", "android", "dev"], { stdio: "inherit" });
  if (r.status === 0) break;
  if (i === 0) setTimeout(() => {}, 2000); // let VPN/docker settle before retry
}

Prevention

When it happens

Trigger: Running `tauri android dev` / `tauri ios dev` in containers or restricted sandboxes where interface enumeration fails, or transiently while the network stack is being reconfigured (VPN connecting, docker creating bridges).

Common situations: Dev containers with dropped capabilities; macOS network extension transitions; VPN clients mid-handoff; systems with hundreds of virtual interfaces in flux.

Related errors


AI-assisted analysis of tauri-apps/tauri@52e4b6e71d (2026-08-20). Data as JSON: /api/errors/d87e0dac44898c1a. Report an issue: GitHub.