php.net |  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
Have you experienced this issue?
Rate the importance of this bug to you:

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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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

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 = "https://google.nl";
$body = file_get_contents($file_contents);
var_dump($body);

Not working gives timeout
$file_contents = "https://google.nl";
$body = file_get_contents($file_contents,null,null,null,null);
var_dump($body);

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

Curl works! so looks like nothing to do with network setup
 [2017-02-04 16:08 UTC] rasmus@php.net
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] peehaa@php.net
-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

<?php
error_reporting(E_ALL);
$file_contents = "https://google.nl";
$contextOptions = array(
    'ssl' => array(
        'verify_peer' => false,
    )
);
$context = stream_context_create($contextOptions);
$body = file_get_contents($file_contents, 0, $context);
var_dump($body);
?>

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: Fri Apr 19 01:01:28 2024 UTC