During the process of migrating some old blogs for a client we encountered issues importing media from the old server by means of Wordpress’ importer, with the import appearing to hang. We tried the more verbose plugin Attachement Importer, and that reported:
Remote server did not respond
Errors. Very odd the old server was accessible, the URLs worked. The server doing the import could
fetch those files from the command line, what could be wrong? We traced some of the functions in Wordpress and confirmed there didn’t seem to be anything fundamentally wrong with the code in the plugin (beyond using a depreciated function). We wondered if it was pecular to the importers or if “Wordpress” was unable to connect to anything using it’s own internal code… that proved correct, viewing the Plugins Add New page resulted in a similar error
An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums.
or with verbose debugging enabled:
Warning: An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums. (WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.) in /www/wp-admin/includes/plugin-install.php on line 165
So time to consider the setup: Nginx and PHP-FPM, nothing that odd there. We were running PHP-FPM with it’s chroot functionality enabled to add a little more protection around the install, but everything seemed fine and Wordpress was running. The only thing could be the chroot… bingo, The Wordpress HTTP code was of course triggering a DNS lookup request which in turn was expecting there to be an
/etc/resolv.conf file to obtain name servers from. Within the chroot scope PHP could see this file did not exist and so the DNS lookup failed and caused the errors we were seeing. Adding an
/etc/resolv.conf to the chroot solved this and allowed the image import to proceed.