Solving “curl#6 – getaddrinfo() thread failed to start”
If 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
toY
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.
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.
Yes, depending on the configuration of the system (we believe it’s the IBM i TCP/IP configuration), you may need to specify –ipv4 as in curl –ipv4 https://example.com.