Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion


For appeals, questions and feedback, please email : Exception while resolving host name via InetAddress.getByName()

user-z9e6vFeb 21 2023

I am using "InetAddress.getByName("hostname")" to resolve the host name of smart host before sending the mail through SMTP.

Getting exception while resolving Host : Host Name or service not known. This issue only pops up when I send smtp messages back to back, after initial few success messages I am getting "unknown host exception", but if I restart the server it works fine again for inital few messages.

My observation - It's working fine with Java 7 but on Java 8 facing this issue but couldn't find relevant proofs for the same. Is it really because of Java versions or any other possible solution or reason is there ?

Post Details
Added on Feb 21 2023