Can´t connect using https to Elastic Cloud on GCP with PHP

(Alexandre Góes) #1

I´m trying for a few days to setup a "Hello Word" with my trial account on Elastic Cloud using the Google Cloud Platform.

I had set up the cloud servers and I can connect them directly with the browser on endpoint:

When trying to connect to it with ElasticSearch PHP API, I get the following error: Fatal error: Uncaught Elasticsearch\Common\Exceptions\NoNodesAvailableException: No alive nodes found in your cluster in /home/mysite/public_html/

I´m using a HostGator shared hosting with free SSL certificate to run the php script.

Here is the code:

    require 'vendor/autoload.php';

    use Elasticsearch\ClientBuilder;

    $hosts = [""];

    $client = ClientBuilder::create()

    $params = [
        'index' => 'my_index',
        'type' => 'my_type',
        'id' => 'my_id',
        'body' => ['testField' => 'abc']

    $response = $client->index($params);

    echo $response;


I also tried to install ElasticSearch on localhost. The same code works on localhost if I use http instead of https, but Elastic Cloud on GCP do not support http (as far as I know).

Do anyone have ANY idea of how to make this simple work? I tried a few things like using the CaBundle as pointed in ElasticSearch docs, but no success with it.

(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.