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.

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"

Here is how to allow multithreading in your job, depending on the shell environment you are using:

  • 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. Example: before invoking QSH, call the CL command:
    • ADDENVVAR ENVVAR(QIBM_MULTI_THREADED) VALUE(Y) REPLACE(*YES).
  • SSH or QP2TERM: threads are enabled by default.
  • QP2SHELL: threads not normally supported. Options:
    • Use QSH, then see the QSH section above.
    • If using SBMJOB, start the job with the ALWMLTTHD parameter set to *YES.

After you do this, curl will work correctly.

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

2 replies
  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.