Elasticsearch no alive nodes found in cluster – Resolved
Are you seeing Elasticsearch no alive nodes found in cluster error?
Often when users try to call Elasticsearch from an Application server, it ends up in errors.
This can be due to failed services, wrong application configuration, etc.
At Bobcares, we help customers with Elasticsearch apps as part of our Server Management Services.
In this write-up, we’ll see how we fixed the elasticsearch error.
Where do we see the Elasticsearch no alive nodes found in cluster error?
Let’s first check the scenario in which the error occurs.
Elasticsearch allows us to store, search and analyze big data volumes easily. It is a full-text search engine that stores data in JSON format. It comes useful in managing log files.
Usually, users make use of applications to fetch and view the results from the elasticsearch server. Again, many times application resides on a different server.
When they try to call Elasticsearch from the Application server, it gives an error Fatal error:
Uncaught exception 'Elasticsearch\Common\Exceptions\NoNodesAvailableException' with message 'No alive nodes found in your cluster'
Recently, in one of the customer’s server, the error appeared as
What causes the Elasticsearch error?
We just saw how the error appears. It’s time now to see the common causes of the error.
1. Failed Elasticsearch service
Quite often, the Elasticsearch no alive nodes found in cluster error happens when the underlying service fails.
For showing the search results, the Elasticsearch service should be running on the server. When it is down or not listening, the app may not be able to fetch the results.
2. Incorrect config settings
Similarly, incorrect configuration settings also can trigger errors. This can be related to Elasticsearch search server name, port settings, etc.
This involves settings like:
'host' => 'my-server.xxxx.aws.io', 'port' => 9234, 'scheme' => 'https', 'user' => 'username', 'pass' => 'password'
Here, the elasticsearch server should be able to listen properly on the secure port. Additionally, if there are port restrictions or password problems, it also causes an error.
How we fixed the Elasticsearch no alive nodes found in cluster error
Moving on, let’s now see how our Support Engineers fixed this error for the customer.
As the first step, we checked the status of the Elasticsearch service. We used the command:
systemctl status elasticsearch
And, we found that the Elasticsearch services failed to start on boot. The failed services list on the server appeared as:
[root@xxx system]# systemctl --failed UNIT LOAD ACTIVE SUB DESCRIPTION ● cpanel_php_fpm.service loaded failed failed FPM service for cPanel Daemons ● elasticsearch.service loaded failed failed Elasticsearch
Therefore, we checked the logs and corrected the elasticsearch startup problem. This fixed the error and the application started showing in the results.
Likewise, when there are configuration errors, we double-check the app settings. We correct the host’s setting. We include the http[s]:// in the host address and set the port to 443. Here, we confirm the SSL certificate settings. Or, when using the nonsecure version, we use port 80.
[Struggling with Elasticsearch service failure? We can fix it for you.]
To sum up, the Elasticsearch no alive nodes found in cluster error happens due to service failure or incorrect application settings. Today, we saw how our Support Engineers made Elasticsearch working for the customer.