apache/cassandra · error · ConfigurationException

Unable to obtain public address for node from cloud metadata

Error message

Unable to obtain public address for node from cloud metadata service

What it means

Ec2MultiRegionAddressConfig resolves the node's public IP from the EC2 metadata service (169.254.169.254) when broadcast_rpc_address is unset. If DNS resolution of the fetched public hostname/address fails (UnknownHostException), it throws this ConfigurationException during node initialization.

Source

Thrown at src/java/org/apache/cassandra/locator/Ec2MultiRegionAddressConfig.java:77

    }

    @Override
    public void configureAddresses()
    {
        // use the Public IP to broadcast Address to other nodes.
        try
        {
            InetAddress broadcastAddress = InetAddress.getByName(localPublicAddress);
            DatabaseDescriptor.setBroadcastAddress(broadcastAddress);
            if (DatabaseDescriptor.getBroadcastRpcAddress() == null)
            {
                logger.info("broadcast_rpc_address unset, broadcasting public IP as rpc_address: {}", localPublicAddress);
                DatabaseDescriptor.setBroadcastRpcAddress(broadcastAddress);
            }
        }
        catch (UnknownHostException e)
        {
            throw new ConfigurationException("Unable to obtain public address for node from cloud metadata service", e);
        }

        try
        {
            InetAddress privateAddress = InetAddress.getByName(localPrivateAddress);
            FBUtilities.setLocalAddress(privateAddress);
        }
        catch (UnknownHostException e)
        {
            throw new ConfigurationException("Unable to obtain private address for node from cloud metadata service", e);
        }
    }

    @Override
    public boolean preferLocalConnections()
    {
        // Always prefer re-connecting on private addresses if in the same datacenter (i.e. region)
        return true;

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Set broadcast_rpc_address explicitly in cassandra.yaml so the public-IP lookup isn't needed — or use broadcast_address/private settings appropriate to a private-only subnet
  2. Verify instance metadata access: curl -s http://169.254.169.254/latest/meta-data/public-ipv4 works on the host
  3. Enable IMDSv2 compatibility (token fetch) and ensure the metadata hop limit allows container/nested setups
  4. Check VPC DNS resolution (enableDnsSupport) and that the instance actually has a public IPv4

Example fix

// before (cassandra.yaml)
broadcast_rpc_address: # unset, relies on EC2 metadata
# after
broadcast_rpc_address: 54.210.11.22
Defensive patterns

Strategy: try-catch

Validate before calling

String pub = "curl -s -m 2 http://169.254.169.254/latest/meta-data/public-ipv4".exec();
if (pub == null || pub.isBlank()) throw new IllegalStateException("EC2 public-ipv4 metadata unavailable");

Try / catch

try { Ec2MultiRegionAddressConfig.configureAddresses(); }
catch (ConfigurationException e) { logger.error("Cannot resolve EC2 public address: {}", e.getCause(), e); throw e; }

Prevention

When it happens

Trigger: configureAddresses() catches UnknownHostException from InetAddress.getByName(localPublicAddress) — the metadata service returned an address/hostname that cannot be resolved, or resolution of the external hostname failed.

Common situations: IMDS unreachable or returning empty/garbage (security group or firewall blocking 169.254.169.254); IMDSv2 required but hop limit/token fetch failing; VPC without public IPs (private-only subnets) so the public hostname doesn't resolve; DNS issues inside the VPC.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/f9aa7630a1d52721. Report an issue: GitHub.