apache/hadoop · error · UnknownHostException

No such interface ${strInterface}

Error message

No such interface ${strInterface}

What it means

UnknownHostException('No such interface <name>') thrown by DNS.getIPs (string variant, used to resolve this machine's own IP) when NetworkInterface.getByName(strInterface) and the sub-interface lookup both return null — i.e., the configured network interface name does not exist on the host. The interface usually comes from properties like 'dfs.datanode.dns.interface' or 'mapreduce.tasktracker.dns.interface'; a SocketException during the lookup is caught and degrades to the cached host address instead, so this throw specifically means 'name not found'.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/DNS.java:191

   * 
   */
  public static String[] getIPs(String strInterface,
      boolean returnSubinterfaces) throws UnknownHostException {
    if ("default".equals(strInterface)) {
      return new String[] { cachedHostAddress };
    }
    NetworkInterface netIf;
    try {
      netIf = NetworkInterface.getByName(strInterface);
      if (netIf == null) {
        netIf = getSubinterface(strInterface);
      }
    } catch (SocketException e) {
      LOG.warn("I/O error finding interface {}", strInterface, e);
      return new String[] { cachedHostAddress };
    }
    if (netIf == null) {
      throw new UnknownHostException("No such interface " + strInterface);
    }

    // NB: Using a LinkedHashSet to preserve the order for callers
    // that depend on a particular element being 1st in the array.
    // For example, getDefaultIP always returns the first element.
    LinkedHashSet<InetAddress> allAddrs = new LinkedHashSet<InetAddress>();
    allAddrs.addAll(Collections.list(netIf.getInetAddresses()));
    if (!returnSubinterfaces) {
      allAddrs.removeAll(getSubinterfaceInetAddrs(netIf));
    }

    String ips[] = new String[allAddrs.size()];
    int i = 0;
    for (InetAddress addr : allAddrs) {
      ips[i++] = addr.getHostAddress();
    }
    return ips;
  }

View on GitHub (pinned to 2add963021)

Solutions

  1. List real interfaces on the node with 'ip link show' or 'ifconfig -a'
  2. Set the dns.interface property to an existing interface name, or to 'default' to use the canonical hostname resolution instead
  3. If the interface exists but is named differently per node, use per-node config or switch to 'dfs.datanode.dns.nameserver' + 'dfs.datanode.dns.matcher' hostname-based resolution

Example fix

# before
<property><name>dfs.datanode.dns.interface</name><value>eth0</value></property>  # host only has ens33 -> UnknownHostException at startup

# after
<property><name>dfs.datanode.dns.interface</name><value>ens33</value></property>
Defensive patterns

Strategy: validation

Validate before calling

String ifName = conf.get("dfs.datanode.dns.interface", "default");
if (!"default".equals(ifName) && NetworkInterface.getByName(ifName) == null) {
  throw new IllegalStateException("dfs.datanode.dns.interface " + ifName + " does not exist; found: "
      + Collections.list(NetworkInterface.getNetworkInterfaces()));
}

Try / catch

catch (UnknownHostException e) { /* 'No such interface <name>' */ fail fast at startup with the list of available interfaces; }

Prevention

When it happens

Trigger: Configuration names an interface absent on the machine: 'dfs.datanode.dns.interface=eth0' on a host whose NIC is 'ens33' or 'enp0s3'; typo in the interface name; container/minimal-VM environments that only expose 'lo' or 'eth1'.

Common situations: Cloud images and modern distros using predictable NIC names (ens*, enp*) while configs assume eth0; moving a Hadoop config between bare-metal and VMs; Docker containers with renamed veth interfaces.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/676e4d0707a461f2. Report an issue: GitHub.