title: file_get_contents fails with "getaddrinfo failed: no address associated with hostname"
body: <p>I'm trying to get the page from another host. I do as hph manual says:
  </p>
  
  <pre><code>    $page = file_get_contents('http://www.example.com/');
      echo $page;
  </code></pre>
  
  <p>But it fails and in apache log i get the following:</p>
  
  <pre><code>[Mon Oct 12 18:58:47.676454 2015] [:error] [pid 2971] [client 127.0.0.1:49434] PHP Warning:  file_get_contents(): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /var/www/html/digest/ftry.php on line 2
  [Mon Oct 12 18:58:47.704659 2015] [:error] [pid 2971] [client 127.0.0.1:49434] PHP Warning:  file_get_contents(http://www.example.com/): failed to open stream: php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /var/www/html/digest/ftry.php on line 2
  </code></pre>
  
  <p>While trying to figure out the reason of failure, I checked what <code>nslookup</code> says. When I run <code>nslookup http://www.example.com/</code> it answers something like that:</p>
  
  <pre><code>nslookup http://www.example.com/
  Server:         94.242.57.130
  Address:        94.242.57.130#53
  
  ** server can't find http://www.example.com/: NXDOMAIN
  </code></pre>
  
  <p>When I remove <code>http://</code> from domain name it works fine, returns ip. But when I try to get file with <code>file_get_contents</code> without <code>http://</code>, it looks for the file in the local filesystem (and it's how it's supposed to be).</p>
  
  <p>I've checked <code>phpinfo</code>, <code>allow_url_fopen</code> is <code>On</code> on both local and master levels. I've set the nameserver in my <code>resolv.conf</code> to <code>94.242.57.130</code> (nearest public dns).</p>