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
- 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
- Verify instance metadata access: curl -s http://169.254.169.254/latest/meta-data/public-ipv4 works on the host
- Enable IMDSv2 compatibility (token fetch) and ensure the metadata hop limit allows container/nested setups
- 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
- Always set broadcast_rpc_address explicitly in multi-region EC2 clusters
- Smoke-test IMDS reachability in the AMI/user-data before starting Cassandra
- Prefer static/caching addresses over metadata lookups for address config
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
- Unable to obtain private address for node from cloud metadat
- Replacement host name could not be resolved or scope_id was
- Configured ${configName} "${intf}" could not be found
- Configured ${configName} "${intf}" was found, but had no add
- Set listen_address OR listen_interface, not both
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/f9aa7630a1d52721.
Report an issue: GitHub.