The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

wp_remote_get is failing on certain servers (5 posts)

  1. Mickey Kay
    Posted 2 years ago #

    I have a plugin that utilizes wp_remote_get() to pull in the contents of an external URL, however this fails (404) on various servers (the only one of which I know is http://www.lighttpd.net/) even though the fetched URL exists for sure, and has content.

    I've searched and searched, but not found much info on how to ensure that wp_remote_get is successful across all environments. Does anyone have insights into what causes this to fail and/or workarounds?

    Appreciate the help, thanks!

  2. The easy way is to check to be sure that your version of PHP has the curl module installed and/or enabled. There is no one set of rules for doing this, it depends on your hosting environment and/or server configuration.

  3. Mickey Kay
    Posted 2 years ago #

    Thanks Otto!

    And what would you recommend in the case that cURL isn't enabled? I understand that wp_remote_get() has a series of fallbacks it attempts if curl fails, but it sounds like there are still cases where none work. If that's true, than is there another reliable fallback you recommend.

    Last question - can you clarify what the 'streams' fallback in wp_remote_get is (e.g. file_get_contents)? Thanks!

  4. There is no guaranteed way to fallback forever. At some point, it will fail. You need to fix the underlying problem and do something like enabling curl on the server if you want it to work. WordPress's code can only make a best-effort attempt to try all the different ways, but if they're all broken on that server, then it will just fail.

    The WP_HTTP_Streams class attempts to use the PHP Streams functions to make outgoing HTTP requests.


  5. And what would you recommend in the case that cURL isn't enabled?

    Oh, and what I would recommend here is to a) enable curl or b) switch to a different hosting company. One that you have more control over.

Topic Closed

This topic has been closed to new replies.

About this Topic