elasticsearch-php: NoNodesAvailableException in StaticNoPingConnectionPool.php : No alive nodes found in your cluster
I use elasticsearch v 5.5.2 with laravel 5.3 - scout v -2.0. I a trying to executing below code but I am getting this error. NoNodesAvailableException.
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Elasticsearch\ClientBuilder;
use Elastica\Client as ElasticaClient;
class clientController extends Controller
{
protected $elasticsearch;
protected $elastica;
public function __construct()
{
$this->elasticsearch = ClientBuilder::create()
//->setConnectionPool('\Elasticsearch\ConnectionPool\SniffingConnectionPool', [])
->build();
$elasticConfig=['host'=>"locahost",
"port"=>9200,
"index"=>'pets'];
$this->elastica = new ElasticaClient($elasticConfig);
}
public function elasticsearchTest(){
$param = [
'index' => 'pets',
'type' => 'dog',
'id'=>'1'
];
$res = $this->elasticsearch->get($param);
dump($res);
}
}
NoNodesAvailableException in StaticNoPingConnectionPool.php line 51: No alive nodes found in your cluster It’s working fine in sense. Result:
{
"_index": "pets",
"_type": "dog",
"_id": "1",
"_version": 1,
"found": true,
"_source": {
"name": "tommy",
"age": "3",
"color": "black",
"gender": "male"
}
}
Also working on http://localhost:9200/pets/dog/1. Result:
{"_index":"pets","_type":"dog","_id":"1","_version":1,"found":true,"_source":{
"name":"tommy",
"age":"3",
"color":"black",
"gender":"male"
}
}
I also post this on stackover flow but no response.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 22 (5 by maintainers)
Hi, I’m using AWS ElasticSearch service and I had a similar error ( Uncaught Elasticsearch\Common\Exceptions\NoNodesAvailableException: No alive nodes found in your cluster in …).
I fixed it by doing two things:
I added port 80 at the end of the host url (otherwise ES defaults to 9200) ex: https://{account-specific subdomain}.us-east-2.es.amazonaws.com**:80**
I changed the protocol from https to http.
ex: http😕/{account-specific subdomain}.us-east-2.es.amazonaws.com:80
Now it works fine!
Same problem here.
Using docker.
I can connect with elasticsearch correctly from localhost:9200 elsewhere. But when it comes to elasticsearch-php. I get
No alive nodes found in your cluster
.EDIT
Just found a solution to the problem in this post, you must set the host to the name you assigned to the docker and link php to elasticsearch.
Hello guys,
Unfortunately I am getting this same error. But strange part is, it is working perfectly fine on my localhost:9200
But when I connect this with my elasticsearch server i.e host URL is changed, this throws the above error: “No alive nodes found in your cluster”
I tried every possible solution but couldn’t find anyone facing this similar issue.
In short, Elastic search working fine on localhost, but not working when I connect with other hosting server. Tried with 443 HTTPS and 80,9200 HTTP as well.
Any help will be appreciated. Thanks