file_get_contents - failed to open stream
Posted by: sitestem (---.hillarys.co.uk)
Date: June 03, 2016 05:51PM

Hi all,

I've been trying to find a solution for this problem all afternoon, but can't seem to fix it. I'm trying to access files through file_get_contents but keep being shown the following error:

failed to open stream: No connection could be made because the target machine actively refused it

I'm just trying to read [www.example.com] - so there shouldn't be any problems.

Does anyone know what could cause this? I've made sure the allow_url_fopen is set to On in php.ini and checked other settings, but still keep getting the error.

Could anyone help please?

Thanks,
Mike

Options: ReplyQuote
Re: file_get_contents - failed to open stream
Posted by: Otomatic (Moderator)
Date: June 03, 2016 07:01PM

Hi,

With :
- Wampmanager tray icon -> PHP -> PHP settings -> allow url fopen checked
this code works fine with no error or warning.

<?php
$homepage = file_get_contents('http://www.example.com/');
echo $homepage;
?>

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: file_get_contents - failed to open stream
Posted by: sitestem (---.hillarys.co.uk)
Date: June 09, 2016 01:36PM

That's strange, I checked to see if that option was checked and it was.

Could this be related to my local internet settings do you think?

Thanks!

Options: ReplyQuote
Re: file_get_contents - failed to open stream
Posted by: Otomatic (Moderator)
Date: June 09, 2016 02:45PM

Hi,

> Could this be related to my local internet settings do you think?
I do not think so. The denial of access is really from example.com
Maybe your IP or your Internet service provider is blacklisted.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: file_get_contents - failed to open stream
Posted by: SimonT (---.lightspeed.stlsmo.sbcglobal.net)
Date: June 14, 2016 07:25AM

Is that all of the error message you are getting?

I would expect a bit more that would identify the PHP file and the line in the file where the error is happening??

Options: ReplyQuote


Sorry, only registered users may post in this forum.