grpc/grpc-java · error · ResourceInvalidException

Address is not an IP

Error message

Address is not an IP

What it means

gRPC converts each endpoint's Envoy core.SocketAddress into a java.net.InetSocketAddress using InetAddresses.forString, which only accepts literal IP addresses (no DNS names). If the address string is not a valid IP literal, the endpoint resource is rejected with 'Address is not an IP'.

Source

Thrown at xds/src/main/java/io/grpc/xds/XdsEndpointResource.java:256

      endpoints.add(Endpoints.LbEndpoint.create(
          new EquivalentAddressGroup(addresses),
          endpoint.getLoadBalancingWeight().getValue(), isHealthy,
          endpoint.getEndpoint().getHostname(),
          endpointMetadata));
    }
    return StructOrError.fromStruct(Endpoints.LocalityLbEndpoints.create(
        endpoints, proto.getLoadBalancingWeight().getValue(),
        proto.getPriority(), localityMetadata));
  }

  private static InetSocketAddress getInetSocketAddress(Address address)
      throws ResourceInvalidException {
    io.envoyproxy.envoy.config.core.v3.SocketAddress socketAddress = address.getSocketAddress();
    InetAddress parsedAddress;
    try {
      parsedAddress = InetAddresses.forString(socketAddress.getAddress());
    } catch (IllegalArgumentException ex) {
      throw new ResourceInvalidException("Address is not an IP", ex);
    }
    return new InetSocketAddress(parsedAddress, socketAddress.getPortValue());
  }

  static final class EdsUpdate implements ResourceUpdate {
    final String clusterName;
    final Map<Locality, LocalityLbEndpoints> localityLbEndpointsMap;
    final List<DropOverload> dropPolicies;

    EdsUpdate(String clusterName, Map<Locality, LocalityLbEndpoints> localityLbEndpoints,
              List<DropOverload> dropPolicies) {
      this.clusterName = checkNotNull(clusterName, "clusterName");
      this.localityLbEndpointsMap = Collections.unmodifiableMap(
          new LinkedHashMap<>(checkNotNull(localityLbEndpoints, "localityLbEndpoints")));
      this.dropPolicies = Collections.unmodifiableList(
          new ArrayList<>(checkNotNull(dropPolicies, "dropPolicies")));
    }

View on GitHub (pinned to 64daddc1f3)

Solutions

  1. Make the xDS management server emit numeric IP literals in socket_address.address for endpoints
  2. Resolve hostnames to IPs upstream (e.g. cluster DNS) before building the Endpoint resource
  3. Verify IPv6 addresses are bare (no brackets, no %zone) e.g. '2001:db8::1'
  4. Check for empty or whitespace-padded address strings in the EDS proto

Example fix

// before
socket_address { address: "backend.default.svc.cluster.local" port_value: 8080 }
// after
socket_address { address: "10.24.1.7" port_value: 8080 }
Defensive patterns

Strategy: validation

Validate before calling

import com.google.common.net.InetAddresses;
// Control-plane side: ensure every endpoint address is a literal IP
for (var lbEndpoint : locality.getLbEndpointsList()) {
  String addr = lbEndpoint.getEndpoint().getAddress().getSocketAddress().getAddress();
  if (addr.isEmpty() || !InetAddresses.isInetAddress(addr)) {
    throw new IllegalArgumentException("Address is not an IP: " + addr);
  }
}

Type guard

boolean isIpLiteral(String address) {
  return address != null && !address.isEmpty()
      && com.google.common.net.InetAddresses.isInetAddress(address);
}

Try / catch

// Client side: inspect watcher error containing 'Address is not an IP'
@Override public void onError(Status error) {
  if (error.getDescription().contains("Address is not an IP")) {
    logger.log(WARNING, "EDS resource has non-IP endpoint address: " + error.getDescription());
  }
}

Prevention

When it happens

Trigger: An EDS ClusterLoadAssignment (or listener address) contains socket_address.address that is a hostname, an empty string, an IPv6 with zone id, or otherwise not parseable as an IP literal; getInetSocketAddress throws ResourceInvalidException.

Common situations: Control plane resolves endpoints to DNS names instead of IPs; Istio emits workload addresses in hostname form; IPv6 addresses written with brackets or scope IDs; typos in hand-written bootstrap/EDS resources.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of grpc/grpc-java@64daddc1f3 (2026-09-08). Data as JSON: /api/errors/354c14685bf8a1f1. Report an issue: GitHub.