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

**URL:** https://discuss.elastic.co/t/can-t-connect-using-https-to-elastic-cloud-on-gcp-with-php/149029
**Category:** Elasticsearch
**Created:** [September 18, 2018, 9:37pm UTC](https://discuss.elastic.co/t/can-t-connect-using-https-to-elastic-cloud-on-gcp-with-php/149029 "2018-09-18T21:37:08Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![alexandregoes](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@alexandregoes](https://discuss.elastic.co/u/alexandregoes)
#### Post date: [September 18, 2018, 9:37pm UTC](https://discuss.elastic.co/t/can-t-connect-using-https-to-elastic-cloud-on-gcp-with-php/149029/1 "2018-09-18T21:37:08Z")

</div>

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:[https://7fea4de80333428485717a0da463ce05.us-central1.gcp.cloud.es.io:9243/](https://7fea4de80333428485717a0da463ce05.us-central1.gcp.cloud.es.io:9243/)

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/mysite.com/vendor/elasticsearch/elasticsearch/src/Elasticsearch/ConnectionPool/StaticNoPingConnectionPool.php

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

Here is the code:

```auto
    <?php
    require 'vendor/autoload.php';

    use Elasticsearch\ClientBuilder;

    $hosts = ["https://elastic:mypassword@7fea4de80333428485717a0da463ce05.us-central1.gcp.cloud.es.io:9243/"];

    $client = ClientBuilder::create()
                        ->setHosts($hosts)
                        ->build();

    $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.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [October 16, 2018, 9:37pm UTC](https://discuss.elastic.co/t/can-t-connect-using-https-to-elastic-cloud-on-gcp-with-php/149029/2 "2018-10-16T21:37:08Z")

</div>

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