title: Can't connect to localhost from Httpful php rest client
body: <p>I am using <a href="http://phphttpclient.com" rel="nofollow">http://phphttpclient.com</a> to try to connect to a simple service running on localhost:8090.</p>
  
  <p>My code is:</p>
  
  <pre><code>$url = "http://127.0.0.1:8090/animal-speak";
  $response = \Httpful\Request::get($url)
              -&gt;send();
  echo "{$response-&gt;body}"
  </code></pre>
  
  <p>and I get this error:</p>
  
  <blockquote>
    <p>Fatal error: Uncaught Httpful\Exception\ConnectionErrorException: Unable to connect to "<a href="http://127.0.0.1:8090/animal-speak" rel="nofollow">http://127.0.0.1:8090/animal-speak</a>": 7 Failed to connect to 127.0.0.1 port 8090: Connection refused in /var/www/vendor/nategood/httpful/src/Httpful/Request.php:1028 Stack trace: #0 /var/www/vendor/nategood/httpful/src/Httpful/Request.php(204): Httpful\Request->buildResponse(false) #1 /var/www/html/index.php(17): Httpful\Request->send() #2 {main} thrown in /var/www/vendor/nategood/httpful/src/Httpful/Request.php on line 1028</p>
  </blockquote>
  
  <p>I have also tried using Guzzle Http client as well and get exactly the same error which leads me to believe this is a php / libcurl problem? The service is definitely up, I can see it in the browser and can curl to it on the command line.
  Thanks</p>
  
  <p>EDIT: if I don't use localhost, and instead use a remote endpoint it works fine.</p>