# Connect to host error using php client - any ideas?

**URL:** <https://discuss.elastic.co/t/connect-to-host-error-using-php-client-any-ideas/27662>\
**Category:** Elasticsearch\
**Created:** [August 19, 2015, 10:02am UTC](https://discuss.elastic.co/t/connect-to-host-error-using-php-client-any-ideas/27662 "2015-08-19T10:02:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rsmarshall](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rsmarshall/32/4264_2.png) [@rsmarshall](https://discuss.elastic.co/u/rsmarshall)\
**Post date:** [August 19, 2015, 10:02am UTC](https://discuss.elastic.co/t/connect-to-host-error-using-php-client-any-ideas/27662/1 "2015-08-19T10:02:18Z")

</div>

At what seems like random intervals I am seeing the following error in my application logs:

RROR: exception 'Elasticsearch\Common\Exceptions\Curl\CouldNotConnectToHost' with message 'couldn't connect to host'

It's in vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/AbstractConnection.php:320.

I can't find anything else in the logs, so any pointers on where to look for the problem are greatly appreciated.

php version info:

PHP 5.3.10-1ubuntu3.18 with Suhosin-Patch (cli) (built: Apr 17 2015 15:11:25)  
Copyright (c) 1997-2012 The PHP Group  
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies  
with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans

I know it's an old version, old server we are trying to get the client to ok the upgrade. It's Ubuntu 12.04 LTS, Elastic search client v1.3.4

The search method is"

```
/**
 * Returns an array of products IDs for products matching the search query
 *
 * @param string $query
 * @return array
 */
public function search($query)
{
    if (is_numeric($query)) {
        $return = $this->_client->search(
            array(
                'index' => self::INDEX,
                'type' => self::TYPE,
                'body' => array(
                    'query' => array(
                        'multi_match' => array(
                            'query' => $query,
                            'fields' => array('id', 'barcodes'),
                        ),
                    ),
                    'size' => '5000',
                ),
            )
        );
    } else {
        $search = array(
            'index' => self::INDEX,
            'type' => self::TYPE,
        );

        $words = explode(' ', $query);
        foreach ($words AS $word) {
            $search['body']['query']['bool']['must'][] = array('wildcard' => array(
                    '_all' => array(
                        'value' => $word.'*',
                    ),
                )
            );
        }

        $search['body']['size'] = 5000;

        $return = $this->_client->search($search);
            
    } 

    $productIds = array();

    if (!empty($return['hits']['hits'])) {
        foreach ($return['hits']['hits'] as $hit) {
            $productIds[] = $hit['_id'];
        }
    }

    return $productIds;
}

```

In the elasticlog file all I have is:

```
[2015-08-19 09:52:05,412][INFO][node] [Titanium Man] version[1.0.1], pid[5231], build[5c03844/2014-02-25T15:52:53Z]
[2015-08-19 09:52:05,469][INFO][node] [Titanium Man] initializing ...
[2015-08-19 09:52:05,569][INFO][plugins] [Titanium Man] loaded [], sites []
[2015-08-19 09:52:27,912][INFO][node] [Titanium Man] initialized
[2015-08-19 09:52:27,913][INFO][node] [Titanium Man] starting ...
[2015-08-19 09:52:29,242][INFO][transport] [Titanium Man] bound_address {inet[/0:0:0:0:0:0:0:0:9300]}, publish_address {inet[/10.242.35.38:9300]}
[2015-08-19 09:52:32,956][INFO][cluster.service] [Titanium Man] new_master [Titanium Man][3iruajH_SeqaSd-3HYyw9g][srv-odkkt][inet[/10.242.35.38:9300]], reason: zen-disco-join (elected_as_master)
[2015-08-19 09:52:32,995][INFO][discovery] [Titanium Man] elasticsearch/3iruajH_SeqaSd-3HYyw9g
[2015-08-19 09:52:33,082][INFO][http] [Titanium Man] bound_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish_address {inet[/10.242.35.38:9200]}
[2015-08-19 09:52:36,040][INFO][gateway] [Titanium Man] recovered [1] indices into cluster_state
[2015-08-19 09:52:36,042][INFO][node] [Titanium Man] started

```

About 15 mins after a restart my cluster health is:

```
{"cluster_name":"elasticsearch","status":"yellow","timed_out":false,"number_of_nodes":1,"number_of_data_nodes":1,"active_primary_shards":5,"active_shards":5,"relocating_shards":0,"initializing_shards":0,"unassigned_shards":5}

```

Thanks

---

<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:** [July 5, 2017, 11:55pm UTC](https://discuss.elastic.co/t/connect-to-host-error-using-php-client-any-ideas/27662/2 "2017-07-05T23:55:03Z")

</div>


