title: Difference between a "Connection Refused" exception and a timeout in HttpClient
body: <p>I'm trying to determine whether a device on a network is running a web server or not using Java. To do this I'm using Apache's HttpClient. I send a request and if the device runs a web server I get a response - pretty simple.</p>
  
  <p>However, if a web server is not running then I've observed 2 things happen:</p>
  
  <ul>
  <li>The request will be ignored and a timeout will occur</li>
  <li><p>An exception will be thrown. In particular, it will look like this:</p>
  
  <p>org.apache.http.conn.HttpHostConnectException: Connect to 192.168.12.133:80 [/192.168.12.133] failed: Connection refused: connect</p></li>
  </ul>
  
  <p>Is there anything that can be inferred about the device that I'm trying to connect to when I receive the "Connection refused" exception vs. getting no response at all?</p>
  
  <p>Edit:</p>
  
  <p>Just to clarify: What I'm doing is running this against DEVICES on a local network. That means NAS boxes, routers, Windows computers, iPads, etc. Some will have embedded web servers, others will not. Most will not have firewalls.</p>
  
  <p>I also know with 100% certainty that the device is up and running.</p>