Parviz Nekoie
Parviz Nekoie

Reputation: 21

elasticsearch php api Elasticsearch\Common\Exceptions\NoNodesAvailableException

I have the following PHP script:

$client = Elasticsearch\ClientBuilder::create()->build();
$params = [
    'index'  => 'my_index',
    'type'   => 'My_type',
    'id'     => 'AVlV2YcFAEkAZoTQQTlH'
];
var_dump( $client->get($params));

When I run the script through the command line using php a.php it works fine but when I visit the page at http://localhost/a.php when it is running with Apache, I recieve the following error:

Type: Elasticsearch\Common\Exceptions\NoNodesAvailableException
Message: No alive nodes found in your cluster

Upvotes: 0

Views: 808

Answers (1)

Parviz Nekoie
Parviz Nekoie

Reputation: 21

This is a network(firewall) issue.

run this command:

setsebool -P httpd_can_network_connect on

SELinux doesn't allow httpd daemon to talk to the elastic service.

Upvotes: 2

Related Questions