Support » Networking WordPress » CURL and similar functions failing on local server names

  • Resolved benbakelaar


    Whenever a local server file is referenced via URL, the load function times out. Examples of functions: file_get_contents(), any of the CURL stuff, getimageresize().

    I’ve checked and allow_url_fopen is enabled. Also CURL is installed.

    The problem surfaced in two scenarios:

    1. I installed the paid version of WP to iPad. It attempts to load a file via URL when using the getimageresize() function, and times out. The timeout is what shows up in the php_errors.log.

    2. I installed the FeedWordPress plugin, and when attempting to load an RSS feed from a Drupal site on a different sub-domain server, it fails.


    A. 1 web server –
    B. 1 Drupal site –
    C. 1 WP multi-site install –<instance>

    Both of the problems are surfacing in C. The WP to iPad plugin cannot load an image via URL/HTTP request that is on the same server C. The FeedWordPress plugin cannot load an RSS feed via URL/HTTP request that is on B.

    I am positive this is due to the .htaccess rewrite rules. I need to figure out how to write some exception rules so that when a WP instance on C requests a URL, it resolves correctly. FYI I even tried via IP address, that didn’t work.

    BUT, I can write a simple <?php echo file_get_contents(“”); ?> script and this works fine on B and C. So again the only issue is a URL/HTTP request from B or C that attempts to load a resource on B or C.

    Any help appreciated!

Viewing 13 replies - 1 through 13 (of 13 total)
  • I don’t know how to interpret this section of the .htaccess file but I think this is what is interfering.

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
    RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
    RewriteRule . index.php [L]

    Here are the two errors:

    This is the failure of the WP to iPad plugin (on to load an image resource on the same domain (

    [23-Jul-2012 17:05:35] PHP Warning:  getimagesize( failed to open stream: Connection timed out in /var/www/community/wp-content/plugins/wp-to-ipad/themes/appzine/header.php on line 71

    This is the failure of the FeedWordPress plugin installed on to import an RSS feed from Note it is the same server, just a different sub-domain.

    [23-Jul-2012 15:02:33] PHP Warning:  file_get_contents( failed to open stream: Connection timed out in /var/www/community/testrss.php on line 3

    There’s no ‘paid’ version of WP for your iPad. What on earth are you talking about?

    That really has little to do with my question, but this is it.

    With WP-to-iPad you can easily create and publish an iPad magazine with WordPress. Offer your WordPress blog readers an optimized version for iPad with just a few clicks! Opt for the paid version to take advantage of various options to customize your iPad magazine.

    Both of those actually imply the same thing: You have a server configuration problem.

    I ran the same test with pulling in a feed via CURL on my local server (from another install of a separate app on the same server within the same account), and had no issues. So something on the server’s got to be wrong, as WP doesn’t actually do much with CURL except call it from your server.

    Hmm so you don’t think it is related to the .htaccess file? You tested on a multi-site install with sub-directories? I don’t think it’s the same environment if it’s two separate installed instances of WP regular. I’ve never had issues like this with WP regular, just multisite, which I know is a tricky beast.

    Here are some details on the server from phpinfo:

    Apache Version 	Apache/2.2.17 (Ubuntu)
    User/Group 	www-data(33)/33
    Server Root 	/etc/apache2
    DOCUMENT_ROOT 	/var/www/community/
    allow_url_fopen	On	On
    allow_url_include	Off	Off
    cURL support 	enabled
    cURL Information 	7.21.3

    In tests using file_get_contents() and a curl() function, I can load without issue. I assume this means I can load any other domain as well. But if I try to load a URL on the server itself, e.g., or a URL on a different sub-domain on the same server, e.g., the request times out with the “failed to open stream” error. Both of these URLs exist and can be loaded in a browser.

    Obviously the server is having trouble referring to itself. Looking for ideas about why this might be. I think it is related to the htaccess rewrite code. I’ve been working with Apache/PHP/MySQL and WordPress for many years now, but only recently with multi-site. Everything functions normally, just this issue.

    The plugins that are actually “causing” this issue are:
    – WP-to-iPad (renders an iPad version of site)
    – FeedWordPress (allows you to import RSS feeds)

    But the problem has nothing to do with the plugins themselves, just the functions they are using to retrieve resources on the server.

    Also here is the Apache virtualhost configuration:

    <VirtualHost *:80>
        ServerAdmin me@myserver
        DocumentRoot /var/www/community/
        ServerAlias community
        RewriteEngine On
        RewriteOptions inherit
        CustomLog /var/log/apache2/community.log combined
        Options -Indexes FollowSymLinks

    And I wonder if it has something to do with this error when I restart Apache?

    root@PPLWebServer:/var/www/community# service apache2 restart
     * Restarting web server apache2                                                apache2: Could not reliably determine the server's fully qualified domain name, using for ServerName
     ... waiting apache2: Could not reliably determine the server's fully qualified domain name, using for ServerName

    Hmm so you don’t think it is related to the .htaccess file? You tested on a multi-site install with sub-directories?

    I have a subdirectory install, a subdomain, and a mapped domain 🙂 I get around 😉

    I acutally pull in RSS like that from a wiki and a gallery all the time, never had an issue.

    But … The FQDN error certainly is suspect.

    Yea I’m poking around for support for the FQDN/configuration error. I suppose I might eventually be able to figure it out but I just don’t understand every layer in enough detail to know how to fix or isolate the issue.

    Re: my actual issues, I did manage to solve one of them. I tricked the FeedWordPress plugin by using as the feed address, rather than

    That won’t fix my problem with resource loading on the WP-to-iPad plugin though.

    No, but it does somewhat confirm that the FQDN is the cause here.

    FINALLY fixed!

    I started to narrow down on DNS issues as the cause. (duh)

    I checked out /etc/resolv.conf, and was reading articles about editing it. But then I tried some “ping” commands to the sub-domains in question, and the pings worked. So it didn’t appear to be DNS issue.

    Then I found this question, which pretty much exactly described the same problem I was having:

    No resolution there, but I took another look at the /etc/hosts file. Because I was able to “trick” FeedWordPress into importing my main website’s RSS feed via, I decided to add entries for the sub-domains in /etc/hosts under (they were already entered as the external IP).


    I did have to restart networking – on Ubuntu Linux, it is /etc/init.d/networking restart.

    I hope this info ends up helping someone else some day. Really frustrating. I guess the answer is:

    If you are running multiple virtual hosts on an Apache server, and want CURL/file_get_contents and similar functions to be able to access resources via FQDN, you need to associate the sub-domains with the localhost address ( in your /etc/hosts file.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘CURL and similar functions failing on local server names’ is closed to new replies.