|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74040 file_get_contents not working anymore for adresses not on domain (timeout)
Submitted: 2017-02-03 15:00 UTC Modified: 2017-05-21 04:22 UTC
From: everdij at gmail dot com Assigned:
Status: No Feedback Package: *General Issues
PHP Version: 7.1.1 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
23 + 38 = ?
Subscribe to this entry?

 [2017-02-03 15:00 UTC] everdij at gmail dot com
file_get_contents not working anymore for adresses not on domain (timeout)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-02-03 15:07 UTC]
-Status: Open +Status: Feedback
 [2017-02-03 15:07 UTC]
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.

Make sure it's not a problem with your network configuration.
 [2017-02-04 12:06 UTC] everdij at gmail dot com
-Status: Feedback +Status: Open
 [2017-02-04 12:06 UTC] everdij at gmail dot com
Not working (gives time out)
$file_contents = "";
$body = file_get_contents($file_contents);

Not working gives timeout
$file_contents = "";
$body = file_get_contents($file_contents,null,null,null,null);

$file_contents = "../local_file.txt";
$body = file_get_contents($file_contents);

Curl works! so looks like nothing to do with network setup
 [2017-02-04 16:08 UTC]
That's still not enough details. Your example works for us. Try it on a different server. This is most likely a local network configuration issue. Like a firewall blocking outbound http requests.
 [2017-05-08 20:44 UTC]
-Status: Open +Status: Feedback
 [2017-05-14 18:44 UTC] ganlvtech at qq dot com
I tried your test script and got the following warning.

SSL routines:ssl3_get_server_certificate:certificate verify failed

$file_contents = "";
$contextOptions = array(
    'ssl' => array(
        'verify_peer' => false,
$context = stream_context_create($contextOptions);
$body = file_get_contents($file_contents, 0, $context);

If I set verify_peer to false, it works.
 [2017-05-19 13:45 UTC] everdij at gmail dot com
[2017-05-14 18:44 UTC] ganlvtech at qq dot com

Tnx that is the solution
 [2017-05-21 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 23 05:01:28 2024 UTC