{"record":{"id":"d8821b5a55a641f6","repo":"apache/flink","slug":"address-cannot-be-resolved","errorCode":null,"errorMessage":"Address cannot be resolved: {}","messagePattern":"Address cannot be resolved: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/util/NetUtils.java","lineNumber":310,"sourceCode":"     *\n     * @param address The address to be included in the URL.\n     * @param port The port for the URL address.\n     * @return The proper URL string encoded IP address and port.\n     */\n    public static String ipAddressAndPortToUrlString(InetAddress address, int port) {\n        return ipAddressToUrlString(address) + ':' + port;\n    }\n\n    /**\n     * Encodes an IP address and port to be included in URL. in particular, this method makes sure\n     * that IPv6 addresses have the proper formatting to be included in URLs.\n     *\n     * @param address The socket address with the IP address and port.\n     * @return The proper URL string encoded IP address and port.\n     */\n    public static String socketAddressToUrlString(InetSocketAddress address) {\n        if (address.isUnresolved()) {\n            throw new IllegalArgumentException(\n                    \"Address cannot be resolved: \" + address.getHostString());\n        }\n        return ipAddressAndPortToUrlString(address.getAddress(), address.getPort());\n    }\n\n    /**\n     * Normalizes and encodes a hostname and port to be included in URL. In particular, this method\n     * makes sure that IPv6 address literals have the proper formatting to be included in URLs.\n     *\n     * @param host The address to be included in the URL.\n     * @param port The port for the URL address.\n     * @return The proper URL string encoded IP address and port.\n     * @throws java.net.UnknownHostException Thrown, if the hostname cannot be translated into a\n     *     URL.\n     */\n    public static String hostAndPortToUrlString(String host, int port) throws UnknownHostException {\n        return ipAddressAndPortToUrlString(InetAddress.getByName(host), port);\n    }","sourceCodeStart":292,"sourceCodeEnd":328,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/util/NetUtils.java#L292-L328","documentation":"NetUtils.socketAddressToUrlString requires a resolved InetSocketAddress; if it was created from a hostname that DNS could not resolve, isUnresolved() is true and this IllegalArgumentException is thrown with the unresolved host string. Flink needs the concrete IP to build the URL representation (including IPv6 formatting). It usually surfaces an upstream DNS failure.","triggerScenarios":"new InetSocketAddress(\"unknown.host.example\", 8081) followed by socketAddressToUrlString; hostname resolved at object creation but lookup silently failed, leaving address null inside the socket address.","commonSituations":"Kubernetes/Docker service names not resolvable from the JobManager; /etc/hosts or DNS misconfiguration; a task manager registering with a name the client cannot resolve; transient DNS outage at startup.","solutions":["Verify the hostname resolves from the machine throwing the error (nslookup/getent hosts).","Fix DNS/hosts entries or use IP addresses / properly configured service discovery.","Resolve explicitly with InetAddress.getByName and construct the socket address from the InetAddress so failures happen as UnknownHostException with clearer context."],"exampleFix":"// before\nInetSocketAddress sa = new InetSocketAddress(host, port);\nString url = NetUtils.socketAddressToUrlString(sa); // throws if DNS failed\n\n// after\nInetAddress addr = InetAddress.getByName(host); // throws UnknownHostException early\nInetSocketAddress sa = new InetSocketAddress(addr, port);\nString url = NetUtils.socketAddressToUrlString(sa);","handlingStrategy":"validation","validationCode":"static InetSocketAddress requireResolved(String host, int port) throws UnknownHostException {\n    InetAddress a = InetAddress.getByName(host); // throws early with clear context\n    return new InetSocketAddress(a, port);\n}","typeGuard":null,"tryCatchPattern":"if (socketAddress.isUnresolved()) { throw new UnknownHostException(\"cannot resolve \" + socketAddress.getHostString()); } // before calling socketAddressToUrlString","preventionTips":["Resolve once at startup and pass InetAddress-based sockets.","Add DNS/hosts checks to deployment smoke tests."],"tags":["network","dns","flink-core"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}