0

When i use file_get_contents or curl_exec with an url (http://google.com or other) return false with different context, user_agent, etc... No errors no Warnings

With local files it works, example: file_get_contents("a.txt");

Configuration:

Php.ini is right: allow_url_fopen = On

No Firewall: sudo ufw status: inactive

Phpinfo():

Protocols: dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtmp, rtsp, smtp, smtps, telnet, tftp

Host: x86_64-pc-linux-gnu

SSL: Version OpenSSL/1.0.1e

OpenSSL: support enabled

OpenSSL: Library Version OpenSSL 1.0.1e 11 Feb 2013

OpenSSL: Header Version OpenSSL 1.0.1e 11 Feb 2013

It is a dedicated server, maybe is there a physical firewall? or something I can't control?

Thank you very much

10
  • Try adding a context argument to file_get_contents that includes the useragent - similarly with your curl request Commented Oct 20, 2016 at 11:26
  • let us know what is the error? Commented Oct 20, 2016 at 11:28
  • Yes i tried. user_agent different context. curl_exec doesn't work neither Commented Oct 20, 2016 at 11:28
  • No errors, No warnings, as i said it works with local file Commented Oct 20, 2016 at 11:30
  • you mention google but is that the actual url you tried or is there a specific one for which your calls are failing? Commented Oct 20, 2016 at 11:30

1 Answer 1

0

Thank you all so much for your comments:

Does running wget or curl on the command line of that server work? – apokryfos

Exactly was a server error not a php issue, i just use the easy way to fix it:

After some minutes trying to find something wrong with resolv.conf,head,.d

Just use this solution if you didn't modify nothing manually and you don't have a customized resolv

.I've removed resolvconf:

aptitude purge resolvconf

And i installed it again:

apt-get install resolconf
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.