Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

helfull's avatar

HTTPClient curl could not resolve host, lots of requests

Hi,

i have to make multiple hundred api requests to a 3rd party api, to gather data about multiple entities. The first ~90 work without a problem but then i receive this error in my artisan queue:listen output:

PHP Fatal error:  Uncaught ErrorException: fopen(php://stderr): Failed to open stream: operation failed in...

Which lead me to this guzzle issue https://github.com/guzzle/guzzle/issues/1927#issuecomment-332328987

Opening up the log file i see that this error does come last after this one:

local.ERROR: cURL error 6: Could not resolve host: <REDACTED_FOR_SECURITY_REASON> (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for <REDACTED_FOR_SECURITY_REASON> {"exception":"[object] (Illuminate\Http\Client\ConnectionException(code: 0): cURL error 6: Could not resolve host: <REDACTED_FOR_SECURITY_REASON> (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for <REDACTED_FOR_SECURITY_REASON> at /vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php:665)

Before i am getting told that it cannot resolve the host, it did just fine the first 90 requests which are all to the same domain.

I have tried closing the response stream to the tempfile created by guzzle, which did not resolve any of the problems.

UPDATEs

tried setting curl_setopt($curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); and only check IPv4

tried calling the IP directly, resulted in ssl certificate problems, and i dont have control over the api i am calling

Using guzzle directly does not have any problems.

0 likes
7 replies
sr57's avatar

Could not resolve host

The host does not exist (regarding the nameservers you use)

  • change namesever(s)

  • test with ping, dig , ...

helfull's avatar

Before i am getting told that it cannot resolve the host, it did just fine the first 90 requests which are all to the same domain.

sr57's avatar

Yes, but that does not mean that your nameservers work perfectly all the time.

Replace you domain name by it's IP to avoid using nameservers

helfull's avatar

yeah just tried that, now it does not work because of ssl certificate.

local.ERROR: cURL error 60: SSL: no alternative certificate subject name matches target host name '<REDACTED_FOR_SECURITY_REASON>'
helfull's avatar

Got more progess, using guzzle directly without the HTTPClient does not have these problems.

1 like
paulogsm's avatar

Like using guzzle directly? Doesn't he use the http client from behind? Help me please, I've been having this problem for months

Please or to participate in this conversation.