title: PHP-cURL outbound call works in localhost but not in AWS hosted website despite allowing all traffic
body: <p>I am using curl in my wordpress website(hosted on aws linux) to get some info from a few api's. The problem: I get connection timeout from one of the api only. I contacted the api provider as well and they said the api is working fine. The same code was working fine 5 days back.</p>
  
  <p>Now after going through stack, and running some variations, the results are: 
  1) The same code works in localhost. 
  2) It also works in postman. 
  3) The code was copied from Postman to website but still getting timeout. 4) I edited the aws vpn nacl to allow all traffic in both inbound and outbound in addition to the ones recommended by aws, still getting timeout.</p>
  
  <p>This is the basic function I am using, copied from postman and then modified:</p>
  
  <pre><code>function my2get_curl($myurl){
      $curl = curl_init();
  
      curl_setopt_array($curl, array(
          CURLOPT_URL =&gt; $myurl,
          CURLOPT_SSL_VERIFYPEER =&gt; false,
          CURLOPT_RETURNTRANSFER =&gt; true,
          CURLOPT_ENCODING =&gt; "",
          CURLOPT_MAXREDIRS =&gt; 10,
          CURLOPT_CONNECTTIMEOUT =&gt; 10,
          CURLOPT_TIMEOUT =&gt; 30,
          CURLOPT_HTTP_VERSION =&gt; CURL_HTTP_VERSION_1_1,
          CURLOPT_CUSTOMREQUEST =&gt; "GET",
          CURLOPT_USERAGENT =&gt;$user_agent,
          CURLOPT_HTTPHEADER =&gt; array(
  
                  "cache-control: no-cache",
          ),
      ));
  
      $response = curl_exec($curl);
      $err = curl_error($curl);
      $info = curl_getinfo($curl);
      curl_close($curl);
  
      if ($err) {
        echo "  cURL Error #:" . $err;
        echo json_encode($info,JSON_PRETTY_PRINT);
  
        die('');
      } else {
        return $response;
      }
  }
  </code></pre>
  
  <p>Here is the result/curl error (same for http except the port number changes to 80):</p>
  
  <pre><code>    Failed to connect to www.travelpayouts.com port 443: Connection timed out
  </code></pre>
  
  <p>curl_info:</p>
  
  <pre><code>    { "url": "https:\/\/www.travelpayouts.com\/whereami?locale=en&amp;callback=useriata&amp;ip=&lt;my.ip.address&gt;", "content_type": null, "http_code": 0, "header_size": 0, "request_size": 0, "filetime": -1, "ssl_verify_result": 0, "redirect_count": 0, "total_time": 21.03931, "namelookup_time": 0.066799, "connect_time": 0, "pretransfer_time": 0, "size_upload": 0, "size_download": 0, "speed_download": 0, "speed_upload": 0, "download_content_length": -1, "upload_content_length": -1, "starttransfer_time": 0, "redirect_time": 0, "redirect_url": "", "primary_ip": "", "certinfo": [], "primary_port": 0, "local_ip": "", "local_port": 0 }
  </code></pre>
  
  <p>Is there something wrong with the code or (more likely) aws settings  ? How exactly do i find out whats causing the problem and fix it.</p>