php - Laravel : ElasticSearch could not parse host

one text

I am using ElasticSearch on my laravel application. But I keep getting the error Could Not parse Host and in the source its from ClientBuilder.php.

I have made the necessary changes in the .env file also installed elasticdump. And my local elasticsearch server is working just fine.

This is my first time working with elasticSearch can anyone help me ?

This is the error I'm facing : https://i.stack.imgur.com/vOp7P.png

And below is my code :

private function buildConnectionsFromHosts(array $hosts): array
{   
    echo "<pre>";
    print_r($hosts);
    die();
    $connections = [];
    foreach ($hosts as $host) {
        if (is_string($host)) {
            $host = $this->prependMissingScheme($host);
            $host = $this->extractURIParts($host);
        } elseif (is_array($host)) {
            $host = $this->normalizeExtendedHost($host);
        } else {
            $this->logger->error("Could not parse host: ".print_r($host, true));
            throw new RuntimeException("Could not parse host: ".print_r($host, true));
        }

        $connections[] = $this->connectionFactory->create($host);
    }

    return $connections;
}

And this is the output of the above print_r :

Array (
    [0] => 
)

Source