WordPress.org

Ready to get started?Download WordPress

Forums

wp_remote_get is failing on certain servers (5 posts)

  1. Mickey Kay
    Member
    Posted 2 months 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. Samuel Wood (Otto)
    Tech Ninja
    Posted 2 months ago #

    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
    Member
    Posted 2 months 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. Samuel Wood (Otto)
    Tech Ninja
    Posted 2 months ago #

    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.

    http://www.php.net/manual/en/ref.stream.php

  5. Samuel Wood (Otto)
    Tech Ninja
    Posted 2 months ago #

    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.

Reply

You must log in to post.

About this Topic