Jump to content

Permission for URL file_get_contents, file, and fread not allowed??


Recommended Posts

I'm trying to read in a file from an outside source, and it seems that either php, apache, or my server isn't letting me do it. Perhaps if I show you the simple php script and associated error you can tell me what is wrong?

 

test.php

<?php
      $file   = file_get_contents('http://dynamic.zoneedit.com/checkip.html');
?>

 

associated errors


Warning: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/dns/test.php on line 3

Warning: file_get_contents(http://dynamic.zoneedit.com/checkip.html) [function.file-get-contents]: failed to open stream: Connection refused in /var/www/dns/test.php on line 3

 

I'm not interested in using cURL or an alternate method. I just want to know what is wrong.

After searching around I found out that those errors are from my DNS being messed up. I had configured my server to run name based virtual hosts, but apparently messed up the resolv.conf. Once I fixed that everything is OK. The real problem is that I really don't know what I'm doing... but I guess all of this is part of a learning process.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.