title: Guzzle Cannot make GET request to the localhost (port: 80, 8000, 8080, etc )
body: <p>Currently using Laravel 5.5 and Guzzle that comes together with the laravel installer.</p>
  
  <p>I am trying to make GET request (error occur with other HTTP requests as well) but don't seem work.</p>
  
  <p>This code does not work:</p>
  
  <pre><code>public function callback(Request $request)
  {
      $code = $request-&gt;code;
  
      $client = new Client(['exceptions' =&gt; false]);
  
      try {
        $response = $client-&gt;request('GET', 'http://localhost/api/tests');
          // $response = $http-&gt;request('POST', Config::get('app.url') . '/oauth/token', [
          //     'form_params' =&gt; [
          //         'grant_type' =&gt; 'authorization_code',
          //         'client_id' =&gt; Config::get('oauth_client.client_id'),
          //         'client_secret' =&gt; Config::get('oauth_client.client_secret'),
          //         'redirect_uri' =&gt; Config::get('oauth_client.redirect_uri'),
          //         'code' =&gt; $code,
          //     ],
          // ]);
          // return json_decode((string) $response-&gt;getBody(), true);
      } catch (\Exception $e) {
          dd($e);
      }
      dd($response-&gt;getBody());
      return;
  }
  </code></pre>
  
  <p>But this code below is work very well</p>
  
  <pre><code>public function callback(Request $request)
  {
      $code = $request-&gt;code;
  
      $client = new Client(['exceptions' =&gt; false]);
  
      try {
        $response = $client-&gt;request('GET', 'https://www.google.co.id');
          // $response = $http-&gt;request('POST', Config::get('app.url') . '/oauth/token', [
          //     'form_params' =&gt; [
          //         'grant_type' =&gt; 'authorization_code',
          //         'client_id' =&gt; Config::get('oauth_client.client_id'),
          //         'client_secret' =&gt; Config::get('oauth_client.client_secret'),
          //         'redirect_uri' =&gt; Config::get('oauth_client.redirect_uri'),
          //         'code' =&gt; $code,
          //     ],
          // ]);
          // return json_decode((string) $response-&gt;getBody(), true);
      } catch (\Exception $e) {
          dd($e);
      }
      dd($response-&gt;getBody());
      return;
  }
  </code></pre>
  
  <p>I'm not understand why my Guzzle able to request to google.com but unable to connect to my own localhost server (to all ports).</p>
  
  <p>Any help will greatly appreciate.</p>
  
  <p>Thanks,</p>