CURL and HTTPS, “Cannot resolve host”

I found that curl can decide to use IPv6, in which case it tries to resolve but doesn’t get an IPv6 answer (or something to that effect) and times out.

You can try the curl command line switch -4 to test this out:

curl -4 http://x.com

In PHP, you can configure this line by setting this:

curl_setopt($c, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);

Official manual page for this option: https://curl.se/libcurl/c/CURLOPT_IPRESOLVE.html

Leave a Comment