Solving “curl#6 – getaddrinfo() thread failed to start”

Curl-logoIf you download files onto your system using PHP, Yum, RPM, or other tools, there’s a good chance curl is involved, be it part of a library (such as PHP’s curl extension and the Guzzle HTTP client) or called on its own.

The version of curl provided in IBM i PASE uses multiple threads to speed up common tasks such as DNS lookups. When threading support is not available, however, curl fails.

If threads are not enabled when you use curl, you’ll get messages like:

curl#6 - "getaddrinfo() thread failed to start"

You’ll need to allow multithreading in your job. Here are options to enable multithreading:

  • If you use QSH, set the environment variable QIBM_MULTI_THREADED to Y before starting any program that runs curl. This can be done at whatever scope you feel is appropriate; for example, it can be put in a shell (interactively or in a script) before you start the program. Example: before invoking QSH, call the CL command:
    • ADDENVVAR ENVVAR(QIBM_MULTI_THREADED) VALUE(Y) REPLACE(*YES).
  • SSH or QP2TERM enable threads by default.
  • QP2SHELL does not support threads. Change it to QSH and add QIBM_MULTI_THREADED as mentioned above.
  • Alternatively, start the job with the ALWMLTTHD parameter set to *YES.

After you do this, curl shouldn’t have any problems.

This post was based on the curl documentation for IBM i-specific notes.

1 reply
  1. Giles Sadler
    Giles Sadler says:

    Something seems to have changed either in PHP cURL or the way that PHP decides if IPV6 is active. I have had to explicitly tell wordpress not to use IPV6 or cURL stops resolving domain names and the sites all grind to a halt. I am on OS/400 7.2 and PHP 8.1.10.

    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.