Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6800715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:00:14+00:00 2026-05-26T19:00:14+00:00

How do you test if the given hostname really exists in Java? The problem

  • 0

How do you test if the given hostname really exists in Java?

The problem is with some DNS services like Opendns which will return IP address even for non-existent DNS entries and, therefore, InetAddress.getByName( host) will always return something.

However, the host command is able to detect it somehow:

~$ host owqieyuqowiery.com
owqieyuqowiery.com has address 67.215.77.132
Host owqieyuqowiery.com not found: 3(NXDOMAIN)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:00:15+00:00Added an answer on May 26, 2026 at 7:00 pm

    Depends on what you mean by “really exists.” Do you mean that it’s a registered domain, with a website behind it? A host name is just a more easily readable/memorable form vs. an IP address for a given system. In other words, I could have a domain registered (which is just a publicly accessible short name for a system somewhere), and not host a website on a server that said domain points to, and that doesn’t make the domain any less “real”.

    if you just want to lookup A records, here’s a solution:

    • Blog post: http://mowyourlawn.com/blog/?p=8
    • Code: http://mowyourlawn.com/files/DomainRecord.java.txt

    If you want to know what host does, which might shed some light on why it does what it does, there’s some information on it here: http://linux.die.net/man/1/host Basically when this fails, it means the DNS lookup failed. That is, the DNS server(s) that host connected to in order to lookup that domain returned zero results.

    Also, host returns more than just the DNS A record (which is what is used for websites). It will also give you MX (mail server) records, etc.

    Ex:

    $ host google.com
    google.com has address 74.125.225.48
    google.com has address 74.125.225.49
    google.com has address 74.125.225.50
    google.com has address 74.125.225.51
    google.com has address 74.125.225.52
    google.com mail is handled by 20 alt1.aspmx.l.google.com.
    google.com mail is handled by 30 alt2.aspmx.l.google.com.
    google.com mail is handled by 40 alt3.aspmx.l.google.com.
    google.com mail is handled by 50 alt4.aspmx.l.google.com.
    google.com mail is handled by 10 aspmx.l.google.com.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having some problems with a given test, that I'd like to debug
Given an object like: class M(models.Model): test = models.BooleanField() created_date = models.DateTimeField(auto_now_add=True) Given sample
I'd like to make sure a given view in my test is fetching an
In most languages like C# for example given a string you can test (boolean)
I recently had this problem on a test: given a set of points m
I'd like to implement a little test to check connectivity to J2EE services over
I'd like to test whether given SQL statement is syntactically and semantically valid (ie.
Given test.txt containing: test message I want to end up with: testing a message
For example, my goal is to test the code given here: PHP script that
Given the URL (single line): http://test.example.com/dir/subdir/file.html How can I extract the following parts using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.