I've been trying to connect to my own site using both CURL and the PHP file_get_contents() function to get source of my webpage without success. I am running the PHP script on the same server that I am trying to get the HTML source from. CURL doesn't return any errors, not even when using curl_error(), and the PHP file_get_contents() function returns the following:
Warning: file_get_contents([sitename]) [function.file-get-contents]: failed to open stream: Connection refused in [file path] on line 19.
I've no idea why this is. Why would a server actively refuse this connection? How can I stop it?
Thanks
EDIT:
For reference here is my (cURL) code:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.mydomain.co.uk');
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, '');
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: www.mydomain.co.uk'));
$rawHTML = curl_exec($ch);
$err = curl_error($ch);
curl_close($ch);
print $err;
print 'HTML: ' . $rawHTML;