apache/hadoop · error · UnknownHostException

Unresolved host: ${inetAddress}

Error message

Unresolved host: ${inetAddress}

What it means

UnknownHostException thrown by AbstractGangliaSink.emitToGangliaHosts() when an InetSocketAddress in the Ganglia server list is unresolved (isUnresolved() returns true), meaning the hostname could not be resolved to an IP address when the address object was created. The sink refuses to send UDP metric datagrams to a host it cannot resolve. The message embeds the full InetSocketAddress so you can see exactly which configured server is at fault.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/ganglia/AbstractGangliaSink.java:284

  protected void xdr_int(int i) {
    buffer[offset++] = (byte) ((i >> 24) & 0xff);
    buffer[offset++] = (byte) ((i >> 16) & 0xff);
    buffer[offset++] = (byte) ((i >> 8) & 0xff);
    buffer[offset++] = (byte) (i & 0xff);
  }

  /**
   * Sends Ganglia Metrics to the configured hosts
   * @throws IOException raised on errors performing I/O.
   */
  protected void emitToGangliaHosts() throws IOException {
    try {
      for (SocketAddress socketAddress : metricsServers) {
        if (socketAddress == null || !(socketAddress instanceof InetSocketAddress))
          throw new IllegalArgumentException("Unsupported Address type");
        InetSocketAddress inetAddress = (InetSocketAddress)socketAddress;
        if(inetAddress.isUnresolved()) {
          throw new UnknownHostException("Unresolved host: " + inetAddress);
        }
        DatagramPacket packet =
          new DatagramPacket(buffer, offset, socketAddress);
        datagramSocket.send(packet);
      }
    } finally {
      // reset the buffer for the next metric to be built
      offset = 0;
    }
  }

  /**
   * Reset the buffer for the next metric to be built
   */
  void resetBuffer() {
    offset = 0;
  }

View on GitHub (pinned to 2add963021)

Solutions

  1. Resolve the hostname on the affected node: 'getent hosts <host>' or 'nslookup <host>' — if it fails, fix DNS or add an /etc/hosts entry
  2. Use a literal IP address in the servers property ('<prefix>.servers=10.0.0.5:8649') to remove the DNS dependency entirely
  3. Check for typos in the host name in the metrics2 property file for the affected context (e.g., namenode-servers/ganglia context in hadoop-metrics2.properties)
  4. Restart the daemon after fixing resolution so the InetSocketAddress is re-created resolved

Example fix

# before
*.sink.ganglia.servers=gmnd.example.com:8649   # hostname unresolvable -> UnknownHostException on every putMetrics flush

# after
*.sink.ganglia.servers=10.0.0.5:8649            # or fix DNS / add /etc/hosts entry for gmnd.example.com
Defensive patterns

Strategy: validation

Validate before calling

for (SocketAddress a : metricsServers) {
  if (a instanceof InetSocketAddress && ((InetSocketAddress) a).isUnresolved()) {
    throw new IllegalStateException("Ganglia server unresolvable: " + a);
  }
}

Try / catch

catch (UnknownHostException e) { /* message: Unresolved host: <addr> */ LOG.error("Fix DNS or use an IP in the servers property: {}", e.getMessage()); }

Prevention

When it happens

Trigger: A '<prefix>.servers' entry such as 'ganglia.example.com:8649' whose hostname has no DNS record or /etc/hosts entry on the machine running the Hadoop daemon; DNS outage or wrong search domain at the time the sink was initialized; a typo in the host portion of the servers property.

Common situations: Clusters where gmond's hostname is not in DNS; containers or VMs with incomplete /etc/hosts; moving a config between environments where the ganglia host name differs; transient DNS failures at daemon startup.

Related errors


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