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

untymage's avatar

Wait for response until x Then die (Http facade)

How to tell laravel if the response time was more than 3 seconds dont wait and die, I tried timeout and connect_timeout but these arent working and waiting for too long:


Http::withOptions(['connect_timeout' => 3, 'timout' => 3])->get('wronogDsomain.com'));

0 likes
6 replies
click's avatar

you spelled timeout incorrectly, it says timout

untymage's avatar

Ok but not working, it wait for more than 3 second

it says :

cURL error 28: Resolving timed out after 3000 milliseconds

But it took 10 second or more

bugsysha's avatar

Have you tried like it is in the docs?

$response = Http::timeout(3)->get(...);
untymage's avatar

I dont know if it just for me or not, But not working for me, In my pc with low internet connection it wait for more than 10 second or longer , But in my server it's so fast and it throw Illuminate/Http/Client/ConnectionException with message 'cURL error 6: Could not resolve host: immediately no matter what is set for timeout

bugsysha's avatar

But in my server it's so fast and it throw Illuminate/Http/Client/ConnectionException with message 'cURL error 6: Could not resolve host: immediately no matter what is set for timeout

Timeout is not about waiting till it runs out. It is only used when it is having trouble receiving response. If it gets the response that the host does not exists it will exit right away.

Snapey's avatar
Snapey
Best Answer
Level 122

if your networking is broken then normal rules do not apply.

On your local machine with no internet, your machine is trying hard to convert the web address into an IP address for the server it needs to contact. This name resolution may take a long time if your machine believes that it should be able to contact its name servers but cannot.

The request you want to timeout is AFTER connection has been established with the host, but they are taking a long time to give you the answer.

Your server knows the URL is not valid and can abort immediately - no point in waiting if the domain is invalid.

Please or to participate in this conversation.