PHP error guide
cURL error 28 operation timed out: meaning and fix
Error summary
Use explicit realistic timeouts and make the upstream operation bounded. The transfer exceeds CURLOPT_TIMEOUT or connect timeout.
What it means
Use explicit realistic timeouts and make the upstream operation bounded. The transfer exceeds CURLOPT_TIMEOUT or connect timeout.
What the error means
This message means that the transfer exceeds CURLOPT_TIMEOUT or connect timeout. The exact signature distinguishes curl error 28 operation timed out from a generic application failure.
Why PHP produces it
The engine or service reports “cURL error 28 operation timed out” because its required precondition was not met. Use explicit realistic timeouts and make the upstream operation bounded.
PHP version notes
The curl error 28 operation timed out wording here is based on PHP 7.x–8.4; exception forms require JSON_THROW_ON_ERROR where shown; punctuation and exception class names can differ on older branches or vendor builds.
Most common causes
- The immediate input or configuration reaches the specific condition: the transfer exceeds CURLOPT_TIMEOUT or connect timeout
- The code path assumes the prerequisite for curl error 28 operation timed out has already been satisfied.
- For curl error 28 operation timed out, development and production differ in version, extension, permissions, paths, or service configuration.
- An earlier operation returned an unchecked value that is consumed by the line reporting curl error 28 operation timed out.
Minimal examples
BAD — reproduces the problem
$ch = curl_init($url);
curl_exec($ch);
FIXED — safer pattern
$ch = curl_init($url);
curl_setopt_array($ch,[CURLOPT_CONNECTTIMEOUT=>3,CURLOPT_TIMEOUT=>10]);
curl_exec($ch);
Step-by-step diagnosis
- Copy the complete “cURL error 28: Operation timed out after 10001 milliseconds” text and retain the first application stack frame.
- Reproduce curl error 28 operation timed out in the same SAPI and environment listed for this page.
- Before changing curl error 28 operation timed out, inspect the preceding value or directive and verify its type, path, version, and permissions.
- Apply the narrow correction—use explicit realistic timeouts and make the upstream operation bounded—then repeat the original request once.
Fixes
Correct the failing prerequisite
Use explicit realistic timeouts and make the upstream operation bounded
$ch = curl_init($url);
curl_setopt_array($ch,[CURLOPT_CONNECTTIMEOUT=>3,CURLOPT_TIMEOUT=>10]);
curl_exec($ch);
Fail explicitly at the boundary
Validate the condition before the operation that emits curl error 28 operation timed out, and log a safe diagnostic without credentials or full production paths.
Common mistakes when fixing it
- Suppressing curl error 28 operation timed out instead of correcting its upstream condition.
- Testing curl error 28 operation timed out only with the CLI binary when the failing request runs under FPM or Apache.
- Changing a global setting for curl error 28 operation timed out before confirming the site-specific effective configuration.
How to prevent it
- Add a focused test that exercises the boundary responsible for curl error 28 operation timed out.
- Keep runtime versions, extensions, configuration, and deploy artifacts affecting curl error 28 operation timed out reproducible.
- Validate external data and service return values before they can trigger curl error 28 operation timed out.
Web server / environment notes
cli, fpm, linux. The failure occurs where the transfer exceeds CURLOPT_TIMEOUT or connect timeout
Tags: cli,fpm,linux