title: file_get_contents returns failed to open stream: Connection timed out error
body: <p>I was using the following code on my Centos machine to fetch URL response:</p>
  
  <pre><code>&lt;?php
  ini_set('display_errors', 'On');
  $homepage = file_get_contents('http://www.google.com/');
  echo $homepage;
  ?&gt;
  </code></pre>
  
  <p>It returns the error: </p>
  
  <blockquote>
    <p>"Warning: file_get_contents(<a href="http://www.google.com/" rel="nofollow">http://www.google.com/</a>): failed to open stream: Connection timed out in testFGC.php on line 3"</p>
  </blockquote>
  
  <p>I've checked the <code>php.ini</code> file. Everything looks fine. <code>iptables</code> and <code>ip6tables</code> are off. </p>
  
  <p>I've tried using <code>curl</code> instead of <code>file_get_contents</code>, but that doesn't work as well. </p>
  
  <p>But a normal curl on the bash command line works absolutely fine(returns the html content).</p>
  
  <pre><code>curl www.google.com
  </code></pre>
  
  <p>What can be the reason? Can Firewall rules be the problem even though the bash curl is working? Thank you.</p>