title: "connection refused" when my play app makes http call to itself
body: <p>I am implementing a heartbeat endpoint/route using play 2.2.1 built with Scala 2.10.2 (running Java 1.7.0_45).  When
  the heartbeat endpoint is called, I want the controller to make http calls to <code>localhost</code>.  If all of those
  calls are ok, then the heartbeat endpoint will return an OK http response.</p>
  
  <p>When I execute the following url from curl, I get the expected 200 response:
  http://<code>localhost</code>:9000/oauth2/token.  I am also able to telnet to <code>localhost</code> 9000.  </p>
  
  <p>I am also able to use WS successfully with an external URL:</p>
  
  <pre>
      WS.url("http://www.example.com").withHeaders("Content-Type" -> "application/json").get()
  </pre>
  
  <p>However, when I execute it from within my play app, I get a 500 tcp_error response.</p>
  
  <pre>
      WS.url("http://<code>localhost</code>:9000/oauth2/token").withHeaders("Content-Type" -> "application/json").get()
      WS.url("http://<code>127.0.0.1</code>:9000/oauth2/token").withHeaders("Content-Type" -> "application/json").get()
      WS.url("http://HostName:9000/oauth2/token").withHeaders("Content-Type" -> "application/json").get()
  </pre>
  
  <p>Here is the exact error message I receive:</p>
  
  <pre>
  Network Error (tcp_error)
  
  A communication error occurred: "Connection refused"
  The Web Server may be down, too busy, or experiencing other problems preventing it from responding to requests. You may wish to try again at a later time.
  
  For assistance, contact your network support team.
  </pre>
  
  <p>Do I need to configure something to allow a play application to make calls to itself?  Is this a network problem on 
  my box?  If so, why do curl and telnet work?  If a network issue, then it must be a jvm specific networking issue?<br>
  Could it be a security problem with play calling to itself?  Not sure where to go next.</p>