Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: java.net.UnknownHostException : Exception while resolving host name via InetAddress.getByName()

  1. #1
    Junior Member
    Join Date
    Feb 2023
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default java.net.UnknownHostException : Exception while resolving host name via InetAddress.getByName()

    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 ?

  2. #2
    Junior Member
    Join Date
    Mar 2023
    Location
    Vancouver, Canada
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Re: java.net.UnknownHostException : Exception while resolving host name via InetAddress.getByName()

    When you mention Java7 vs Java8, are you referring to the JDK version used to build the application, or the JRE on the runtime platform?

    If you need to reboot the server to fix the problem, then that sounds more like an OS/platform issue rather than Java application issue.
    - Are you confident that the platform's DNS resolvers are acting properly?
    - If you use a platform utility like nslookup or dig, do you notice any unusual?
    - Can you snoop the network traffic to the resolvers using wireshark or tcdump and see what is happening?

    If you are looking-up an SMTP smarthost, shouldn't you only really need to do this once (or very infrequently)? Smarthosts typically wouldn't change their IP addresses often.

Similar Threads

  1. IPv6 validation is failing with java.net.InetAddress
    By maganti in forum What's Wrong With My Code?
    Replies: 1
    Last Post: June 27th, 2014, 02:45 AM
  2. java.rmi.unknownhostexception :unknown host: pc error
    By hgauravnayak in forum Exceptions
    Replies: 0
    Last Post: May 22nd, 2013, 03:58 PM
  3. [SOLVED] Help resolving these errors? Please!
    By ViewtifulAaron in forum What's Wrong With My Code?
    Replies: 17
    Last Post: March 30th, 2013, 08:53 PM
  4. java.net.NoRouteToHostException: No route to host exception in java
    By kgoswami in forum What's Wrong With My Code?
    Replies: 0
    Last Post: November 23rd, 2012, 03:24 AM
  5. DEBUG SMTP: could not connect to host "host.domain.uk", port: 25, response: 421
    By aueddonline in forum What's Wrong With My Code?
    Replies: 0
    Last Post: August 21st, 2012, 04:47 AM