title: PHP- file_get_contents failed to open stream: Connection refused
body: <p>I am using the following API for getting the country code using IP </p>
  
  <pre><code>http://api.hostip.info/country.php?ip=' . $IP
  </code></pre>
  
  <p>Example: on <strong>Localhost</strong></p>
  
  <pre><code>$IP = '202.71.158.30';
  
  //pass the ip as a parameter for follow URL it will return the country
  
  $country_code = file_get_contents('http://api.hostip.info/country.php?ip=' . $IP);
  </code></pre>
  
  <p>and its working fine here and showing the country code.</p>
  
  <p>But it showing error on <strong>Server</strong></p>
  
  <p>Example:</p>
  
  <pre><code>$IP=$_SERVER['REMOTE_ADDR'];
  
  $country_code = file_get_contents('http://api.hostip.info/country.php?ip=' . $IP);
  </code></pre>
  
  <p>Showing following error:</p>
  
  <blockquote>
    <p>Warning:
    file_get_contents(<a href="http://api.hostip.info/country.php?ip=101.63.xx.xxx" rel="noreferrer">http://api.hostip.info/country.php?ip=101.63.xx.xxx</a>)
    [function.file-get-contents]: failed to open stream: Connection
    refused in /srv/disk4/1322145/www/servername.in/app/header.php
    on line 12</p>
  </blockquote>
  
  <p>Whats wrong with this?</p>