Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback, please email oracle-forums_moderators_us@oracle.com

java.net.UnknownHostException : 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=smarthost.demo.com Exception=java.net.UnknownHostException: smarthost.demo.com: 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 ?

Comments
Post Details
Added on Feb 21 2023
0 comments
536 views