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

henock_barakael's avatar

cURL error 28: Operation timed out after 30002 milliseconds

$response = Http::put('http://127.0.0.1:8000/services/update', [
            "reference" => $reference,
            "status" => "Failed",
        ]);

Output

cURL error 28: Operation timed out after 30002 milliseconds with 0 bytes received

How to set timeout none?

in python for example i use async with httpx.AsyncClient(timeout=None) as client:

0 likes
25 replies
Sinnbeck's avatar

Are you using php artisan serve and trying to connect to laravel itself?

mecjos's avatar

@Sinnbeck hi, I'm getting same error while trying to login.. I use passport authentication package and I get this error after move app to sail + docker container.

Sinnbeck's avatar

@IlfanAsykuri This thread is already solved, so if it isnt the same solution, make a new thread with your specific problem

j3ll3yfi5h's avatar

@Sinnbeck using the value -1 caused a cURL error: cURL error 0: The cURL request was retried 3 times and did not succeed. The most likely reason for the failure is that cURL was unable to rewind the body of the request and subsequent retries resulted in the same error. Turn on the debug option to see what went wrong.

using the value 0 should do the trick...

henock_barakael's avatar
$response = Http::put('http://127.0.0.1:8000/services/update', [
            "reference" => $reference,
            "status" => "Failed",
        ])->timeout(-1); 

like this?

henock_barakael's avatar

Great but now I have this error "Maximum execution time of 60 seconds exceeded"

Sinnbeck's avatar

@henock_barakael are you running the request through web request in laravel?

Do you plan to have the user wait for several minutes?

Sinnbeck's avatar

@henock_barakael Do you plan to have the user wait for several minutes? What's the idea behind this? Sounds like something you should handle on a queue

henock_barakael's avatar

@sinnbeck What is strange is that despite this error the query was still able to update the data in the background

Sinnbeck's avatar

@henock_barakael ok and with fastapi it takes more than a minute as well?

Why not use laravel as it was designed? Put the job on a queue using a job. That way it does not really matter if it's a bit slow.

henock_barakael's avatar
Level 1

@sinnbeck i don't know why but i solved issue by using cURL instead of Guzzle

Before

$reference = explode(",",$request->ids);
$response = Http::put('http://127.0.0.1:8000/services/update', [
            "reference" => $reference,
            "status" => "Failed",
]);

After

		$reference = explode(",",$request->ids);

        $curl_post_data = [
            "reference" => $reference,
            "status" => "Failed",
        ];
		$url ="'http://127.0.0.1:8000/services/update";
        $data = json_encode($curl_post_data);
        $ch=curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
        $curl_response = curl_exec($ch);

		$result = json_decode($curl_response,true);

also i increase timeout

public function __construct()
    {
        ini_set('max_execution_time', 1200);
    }
1 like
atif7866's avatar

iam using this $URL = 'N/A'; $apiRequestData = [ 'number' => 'N/A', 'type' => 'text', 'message' => 'New task created: ', 'instance_id' => 'N/A', 'access_token' => 'N/A', ];

    $apiResponse = Http::post($URL, $apiRequestData);

but it show this cURL error 28: Operation timed out after 30002 milliseconds with 0 bytes received

i want to send message in whatsapp

Please or to participate in this conversation.