curl error: 7 Failed to connect to www.******.com port 80: Connection timed out
<p>I am writing code to get content from other URL curl.
My code is working fine on localhost but when I uploaded on server its not working.</p>

<p>It showing <strong>curl error:</strong></p>

<blockquote>
  <p>curl error 7,Failed to connect to www.******.com port 80: Connection
  timed out.</p>
</blockquote>

<p>This is my <strong>Code</strong></p>

<pre><code>function get_data($url) {

    //echo $url;
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

    $data = curl_exec($ch);

    if(!$data ) {
     echo "curl error-&gt;".curl_errno($ch)."-&gt;".curl_error($ch);
    }

    curl_close($ch);

    return $data;    
}
</code></pre>