What are causes of a connection-timeout with fopen()?

Posted on 16th Feb 2014 by admin

Hello! Here is the situation: The server I host my website on just upgraded it's PHP build from 4.4.* to 5.2.4. Not just PHP was upgraded, MySQL, postGres, and (I think) Apache were upgraded as well. Before the upgrade, my site worked perfectly.

But now, whenever I access my site, it takes a long time to complete a request and all that is returned is "Warning: fopen(<THE_URL>) [function.fopen]: failed to open stream: Connection timed out in..."

I know where the error is -- it's in my templating class. I check the remote server's configuration and the directive "allow_url_fopen is enabled and safe_mode is disabled.

The strange thing is that my script works on my local server perfectly which is using PHP build 5.2.5. I looked for any differences between my local-server's PHPINFO() and my remote-server's PHPINFO() and, while I didn't find anything eye-catching yet, I noticed that virtual-directory-support is disabled on my remote-server and it is enabled on my local-server. Would that be what's causing the problem? If not, what are some potential causes for fopen() to behave this way?

Other forums