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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.