guzzle/guzzle · error · LogicException
GuzzleHttp\Handler\CurlHandler should never be unserialized
Error message
GuzzleHttp\Handler\CurlHandler should never be unserialized
What it means
Error "GuzzleHttp\Handler\CurlHandler should never be unserialized" thrown in guzzle/guzzle.
Source
Thrown at src/Handler/CurlHandler.php:130
public function close(): void
{
$this->doClose(true);
}
public function __destruct()
{
try {
$this->doClose(false);
} catch (\Throwable $e) {
// Destructors must not throw.
}
}
public function __unserialize(array $data): void
{
$this->closed = true;
throw new \LogicException(static::class.' should never be unserialized');
}
private function assertOpen(): void
{
if ($this->closed) {
// Programmer misuse (reusing a closed handler), not a transfer failure;
// intentionally a LogicException outside the GuzzleException hierarchy.
throw new \BadMethodCallException('Cannot use the cURL handler after it has been closed.');
}
}
private function doClose(bool $explicit): void
{
if ($this->closed) {
return;
}
$this->closed = true;View on GitHub (pinned to d1cbca7697)
Solutions
- Do not serialize/unserialize CurlHandler; create a new instance with the same constructor options.
Example fix
$handler = new CurlHandler(['max_handles' => 50]);
When it happens
Trigger: Thrown at src/Handler/CurlHandler.php:130 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of guzzle/guzzle@d1cbca7697 (2026-08-06).
Data as JSON: /api/errors/de4163c6a1cf8378.
Report an issue: GitHub.