• 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 https://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!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    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.

    Thread Starter Mickey Kay

    (@mcguive7)

    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!

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    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.

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

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘wp_remote_get is failing on certain servers’ is closed to new replies.