# I can't connect to elasticsearch with SSL through PHP

**URL:** <https://discuss.elastic.co/t/i-cant-connect-to-elasticsearch-with-ssl-through-php/147259>\
**Category:** Elasticsearch\
**Created:** [September 4, 2018, 7:13pm UTC](https://discuss.elastic.co/t/i-cant-connect-to-elasticsearch-with-ssl-through-php/147259 "2018-09-04T19:13:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andres\_Felipe\_Albarr](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Andres\_Felipe\_Albarr](https://discuss.elastic.co/u/Andres_Felipe_Albarr)\
**Post date:** [September 4, 2018, 7:13pm UTC](https://discuss.elastic.co/t/i-cant-connect-to-elasticsearch-with-ssl-through-php/147259/1 "2018-09-04T19:13:09Z")

</div>

I´m trying to connect to ES but it's been impossible.

that's my code in PHP

```
		$hosts = ['https://www.xxxxxxxx.com:6767'];			
		$myCert = 'xxxxxxxxxxxxxx/cert.pem';

		$client = ClientBuilder::create() // Instantiate a new ClientBuilder
		->setHosts($hosts)
		->setSSLVerification($myCert)
		->build(); // Build the client object

```

always the answer is NoNodesAvailableException

No alive nodes found in your cluster  
**StaticNoPingConnectionPool.php** line 51

I hope that you can help me pls.

---

<div class="post-metadata">

**Author:** ![Andres\_Felipe\_Albarr](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Andres\_Felipe\_Albarr](https://discuss.elastic.co/u/Andres_Felipe_Albarr)\
**Post date:** [September 4, 2018, 7:32pm UTC](https://discuss.elastic.co/t/i-cant-connect-to-elasticsearch-with-ssl-through-php/147259/2 "2018-09-04T19:32:07Z")

</div>

I got it! my problem was that I already have installed x-pack plugin in my elasticsearch instance, so the ssl certificates are already inside of elasticsearch.yml file. so the only code that i needed in PHP was:

```
            $hosts = ['https://www.xxxxxxxx.com:6767'];			

	$client = ClientBuilder::create() // Instantiate a new ClientBuilder
	->setHosts($hosts)
	->build(); // Build the client object

```

now it's working

---

<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 2, 2018, 7:32pm UTC](https://discuss.elastic.co/t/i-cant-connect-to-elasticsearch-with-ssl-through-php/147259/3 "2018-10-02T19:32:18Z")

</div>

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