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

crm1's avatar
Level 1

curl timeout

When I try to send a webhook, I encounter a timeout. But only in the Laravel project. When I explicitly specified the domain IP in etc/hosts where I was sending the webhook and sent a request to the server outside the Laravel project, everything worked.

0 likes
5 replies
s4muel's avatar

does the request work outside laravel project even if you dont edit /etc/hosts? if not, the problem is probably in the DNS resolution. if it does, why do you need to edit the hosts file?

the request destination is some outside web or you request your local project? if local project, how do you serve it? apache/nginx or php arstisan serve? if the latter, try reading this: https://laracasts.com/discuss/channels/laravel/not-able-to-get-response-from-get-api-in-laravel

crm1's avatar
Level 1

The location of the request is the external Internet

crm1's avatar
Level 1
private function executeREST($method, $params)
{
    $queryUrl = 'h ttp s://si te. co m/rest/84733/'.env('CURL_KEY').'/' . $method . '.json';
    $queryData = http_build_query($params);

    $curl = curl_init();
    curl_setopt_array($curl, array(
        CURLOPT_SSL_VERIFYPEER => 0,
        CURLOPT_POST => 1,
        CURLOPT_HEADER => 0,
        CURLOPT_RETURNTRANSFER => 1,
        CURLOPT_URL => $queryUrl,
        CURLOPT_POSTFIELDS => $queryData,
    ));

    $result = curl_exec($curl);
    curl_close($curl);

    return json_decode($result, true);
}

here is my code, when it is executed, sending takes a long time and at the end it produces null. maybe there are some errors there, but I don't have an error handler

s4muel's avatar

the spaces in the URL is a mistake or just just a typo? 'h ttp s://si te. co m/rest/84733/'.env('CURL_KEY').'/' . $method . '.json';

try to dump that string in your code and see what you get

$queryUrl = 'h ttp s://si te. co m/rest/84733/'.env('CURL_KEY').'/' . $method . '.json'; //typos or not, just use the line from your actual code
dd($queryUrl);

is the URL correct? does the CURL_KEY and $method replace ok?

crm1's avatar
Level 1

There was a problem with the firewall on the recipient side.

Thanks for the help

Please or to participate in this conversation.