title: How to ping an IP address
body: <p>I am using this part of  code to ping an ip address in java but only pinging localhost is successful and for the other hosts the program says the host is unreachable.
  I disabled my firewall but still having this problem</p>
  
  <pre><code>public static void main(String[] args) throws UnknownHostException, IOException {
      String ipAddress = "127.0.0.1";
      InetAddress inet = InetAddress.getByName(ipAddress);
  
      System.out.println("Sending Ping Request to " + ipAddress);
      System.out.println(inet.isReachable(5000) ? "Host is reachable" : "Host is NOT reachable");
  
      ipAddress = "173.194.32.38";
      inet = InetAddress.getByName(ipAddress);
  
      System.out.println("Sending Ping Request to " + ipAddress);
      System.out.println(inet.isReachable(5000) ? "Host is reachable" : "Host is NOT reachable");
  }
  </code></pre>
  
  <p>The output is:</p>
  
  <blockquote>
    <p>Sending Ping Request to 127.0.0.1<br>
    Host is reachable<br>
    Sending Ping Request to 173.194.32.38<br>
    Host is NOT reachable</p>
  </blockquote>