title: PHP cURL request primary_ip is different than cURL url
body: <p>When making a curl request through PHP, curl gets &quot;couldn't connect to host&quot;. When I dump the curl info the <code>primary_ip</code> is not the ip of the requested server.</p>
  <pre><code>$soapURL =&quot;www.google.com&quot;;
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $soapURL);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_TIMEOUT, 60);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
  $header[] = &quot;SOAPAction: &quot;. &quot;&quot;;
  $header[] = &quot;MIME-Version: 1.0&quot;;
  $header[] = &quot;Content-type: text/xml; charset=utf-8&quot;;
  curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  $result = curl_exec($ch);
  echo curl_getinfo($ch) . '&lt;br/&gt;';
  echo curl_errno($ch) . '&lt;br/&gt;';
  echo curl_error($ch) . '&lt;br/&gt;';
  $info = curl_getinfo($ch);
  var_dump($info);
  </code></pre>
  <p>This works fine on my test server but not on production. On the production server this is the response I get:</p>
  <blockquote>
  <p>Array</p>
  <p>7</p>
  <p>couldn't connect to host
  array(23) { [&quot;url&quot;]=&gt; string(21) &quot;http://www.google.com&quot; [&quot;content_type&quot;]=&gt; NULL [&quot;http_code&quot;]=&gt; int(0) [&quot;header_size&quot;]=&gt; int(0) [&quot;request_size&quot;]=&gt; int(0) [&quot;filetime&quot;]=&gt; int(-1) [&quot;ssl_verify_result&quot;]=&gt; int(0) [&quot;redirect_count&quot;]=&gt; int(0) [&quot;total_time&quot;]=&gt; float(0) [&quot;namelookup_time&quot;]=&gt; float(2.7E-5) [&quot;connect_time&quot;]=&gt; float(0) [&quot;pretransfer_time&quot;]=&gt; float(0) [&quot;size_upload&quot;]=&gt; float(0) [&quot;size_download&quot;]=&gt; float(0) [&quot;speed_download&quot;]=&gt; float(0) [&quot;speed_upload&quot;]=&gt; float(0) [&quot;download_content_length&quot;]=&gt; float(-1) [&quot;upload_content_length&quot;]=&gt; float(-1) [&quot;starttransfer_time&quot;]=&gt; float(0) [&quot;redirect_time&quot;]=&gt; float(0) [&quot;redirect_url&quot;]=&gt; string(0) &quot;&quot; [&quot;primary_ip&quot;]=&gt; string(10) &quot;10.1.99.87&quot; [&quot;certinfo&quot;]=&gt; array(0) { } }</p>
  </blockquote>
  <p><code>primary_ip =&gt; 10.1.99.87</code> is my local machine (not running this PHP code). It seems like curl is trying to connect to my local machine instead of the url I gave it. I tried this from another computer and the IP stayed as my machine, it didn't change to that of the new machine.</p>
  <p>When I use the test server I get:</p>
  <blockquote>
  <p>Array</p>
  <p>0</p>
  <p>array(23) { [&quot;url&quot;]=&gt; string(21) &quot;http://www.google.com&quot; [&quot;content_type&quot;]=&gt; string(24) &quot;text/html; charset=UTF-8&quot; [&quot;http_code&quot;]=&gt; int(405) [&quot;header_size&quot;]=&gt; int(260) [&quot;request_size&quot;]=&gt; int(948) [&quot;filetime&quot;]=&gt; int(-1) [&quot;ssl_verify_result&quot;]=&gt; int(0) [&quot;redirect_count&quot;]=&gt; int(0) [&quot;total_time&quot;]=&gt; float(0.120098) [&quot;namelookup_time&quot;]=&gt; float(0.029716) [&quot;connect_time&quot;]=&gt; float(0.073289) [&quot;pretransfer_time&quot;]=&gt; float(0.073292) [&quot;size_upload&quot;]=&gt; float(815) [&quot;size_download&quot;]=&gt; float(1453) [&quot;speed_download&quot;]=&gt; float(12098) [&quot;speed_upload&quot;]=&gt; float(6786) [&quot;download_content_length&quot;]=&gt; float(1453) [&quot;upload_content_length&quot;]=&gt; float(0) [&quot;starttransfer_time&quot;]=&gt; float(0.119125) [&quot;redirect_time&quot;]=&gt; float(0) [&quot;redirect_url&quot;]=&gt; string(0) &quot;&quot; [&quot;primary_ip&quot;]=&gt; string(14) &quot;74.125.198.106&quot; [&quot;certinfo&quot;]=&gt; array(0) { } }</p>
  </blockquote>
  <p>Which is what is supposed to happen.</p>
  <p>There used to be Linux environment variables set for http_proxy which was set to my machine that I set to be empty. Also making a curl call from the command line works fine. It's just any curl call that php tries to make that fails.</p>
  <p><a href="https://stackoverflow.com/questions/18653805/curlopt-noproxy-does-not-affect-in-php">Similar Problem with workaround solution</a></p>