php
network
ai_generated
true
cURL error 28: Operation timed out after 30001 milliseconds with 0 bytes received
ID: php/curl-timeout
82%Fix Rate
85%Confidence
70Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 83 | active | — | — | — |
Root Cause
cURL timeout errors occur when an HTTP request exceeds the configured timeout threshold. The root cause can be DNS resolution delays, slow upstream servers, network firewall rules, or insufficient timeout configuration for large payloads.
genericWorkarounds
-
88% success Set separate connection and transfer timeouts with retry logic
Set CURLOPT_CONNECTTIMEOUT to 5-10 seconds for the connection phase and CURLOPT_TIMEOUT to a reasonable transfer time. Implement exponential backoff retry logic (e.g., using Guzzle's retry middleware) for transient failures.
-
90% success Move long-running HTTP calls to a background queue
For API calls that may be slow, dispatch them to a queue worker (e.g., Laravel Queue, Symfony Messenger). The web request returns immediately while the queue worker handles the HTTP call with its own timeout settings.
Dead Ends
Common approaches that don't work:
-
Setting CURLOPT_TIMEOUT to an extremely high value like 3600 seconds
72% fail
Very long timeouts cause PHP-FPM workers to hang indefinitely, exhausting the worker pool and making the entire application unresponsive to other requests.
-
Disabling CURLOPT_CONNECTTIMEOUT entirely
68% fail
Without a connection timeout, the request can hang indefinitely on DNS resolution or TCP handshake, blocking the PHP process.
Error Chain
Leads to:
Preceded by:
Frequently confused with: