{"record":{"id":"f9aa7630a1d52721","repo":"apache/cassandra","slug":"unable-to-obtain-public-address-for-node-from-clou","errorCode":null,"errorMessage":"Unable to obtain public address for node from cloud metadata service","messagePattern":"Unable to obtain public address for node from cloud metadata service","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/locator/Ec2MultiRegionAddressConfig.java","lineNumber":77,"sourceCode":"    }\n\n    @Override\n    public void configureAddresses()\n    {\n        // use the Public IP to broadcast Address to other nodes.\n        try\n        {\n            InetAddress broadcastAddress = InetAddress.getByName(localPublicAddress);\n            DatabaseDescriptor.setBroadcastAddress(broadcastAddress);\n            if (DatabaseDescriptor.getBroadcastRpcAddress() == null)\n            {\n                logger.info(\"broadcast_rpc_address unset, broadcasting public IP as rpc_address: {}\", localPublicAddress);\n                DatabaseDescriptor.setBroadcastRpcAddress(broadcastAddress);\n            }\n        }\n        catch (UnknownHostException e)\n        {\n            throw new ConfigurationException(\"Unable to obtain public address for node from cloud metadata service\", e);\n        }\n\n        try\n        {\n            InetAddress privateAddress = InetAddress.getByName(localPrivateAddress);\n            FBUtilities.setLocalAddress(privateAddress);\n        }\n        catch (UnknownHostException e)\n        {\n            throw new ConfigurationException(\"Unable to obtain private address for node from cloud metadata service\", e);\n        }\n    }\n\n    @Override\n    public boolean preferLocalConnections()\n    {\n        // Always prefer re-connecting on private addresses if in the same datacenter (i.e. region)\n        return true;","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/locator/Ec2MultiRegionAddressConfig.java#L59-L95","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before (cassandra.yaml)\nbroadcast_rpc_address: # unset, relies on EC2 metadata\n# after\nbroadcast_rpc_address: 54.210.11.22","handlingStrategy":"try-catch","validationCode":"String pub = \"curl -s -m 2 http://169.254.169.254/latest/meta-data/public-ipv4\".exec();\nif (pub == null || pub.isBlank()) throw new IllegalStateException(\"EC2 public-ipv4 metadata unavailable\");","typeGuard":null,"tryCatchPattern":"try { Ec2MultiRegionAddressConfig.configureAddresses(); }\ncatch (ConfigurationException e) { logger.error(\"Cannot resolve EC2 public address: {}\", e.getCause(), e); throw e; }","preventionTips":["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"],"tags":["ec2","network","metadata-service","dns","startup"],"backgroundTag":"http-request-failed","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}