cancel
Showing results for 
Search instead for 
Did you mean: 

Could not validate a connection to Elasticsearch. No alive nodes found in your cluster

Could not validate a connection to Elasticsearch. No alive nodes found in your cluster

envirament

    win10

    elasticsearch-7.12.1-windows-x86_64

    magento-ce-2.4.2-p1_sample_data-2021-04-23-01-13-20

     xampp-windows-x64-7.4.18-0-VC15-installer_3

    composer 2.0.13

questions: 

     when   installing elasticsearch configuaration in magento installing process," Could not validate a connection to Elasticsearch. No alive nodes found in your cluster" appears. i don't how to solve it.who know this, help.

  localhost:9200

{
  "name" : "DESKTOP-QC5U3TN",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "mT2bx0_CShe_xQ1JLeoZaA",
  "version" : {
    "number" : "7.12.1",
    "build_flavor" : "default",
    "build_type" : "zip",
    "build_hash" : "3186837139b9c6b6d23c3200870651f10d3343b7",
    "build_date" : "2021-04-20T20:56:39.040728659Z",
    "build_snapshot" : false,
    "lucene_version" : "8.8.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

    the elasticsearch install successfully,and work well 

   magento install command:

   

php bin/magento setup:install --base-url="http://localhost/magento/" --db-host="localhost" --db-name="cstg_en" --db-user="root" --db-password="dd123" --admin-firstname="admin" --admin-lastname="admin" --admin-email="user@example.com" --admin-user="admin" --admin-password="admin123" --language="en_US" --currency="USD" --timezone="America/Chicago" --use-rewrites="1" --backend-frontname="admin" --search-engine=elasticsearch7 --elasticsearch-host="localhost" --elasticsearch-port=9200   

 

7 REPLIES 7

Re: Could not validate a connection to Elasticsearch. No alive nodes found in your cluster

I'm having a similar issue. Two days ago I completed an installation successfully, but today on the same machine a new installation is failing. 

 

Testing using curl works fine. 

 

How can I diagnose this?

 

Thanks,

Charith

 

Installing search configuration...

In SearchConfig.php line 81:

  [Magento\Framework\Validation\ValidationException]
  Could not validate a connection to Elasticsearch. Could not parse URI: "http://elastic:passwd@127.0.0.1:9229 "


Exception trace:
  at /var/www/html/mag02/setup/src/Magento/Setup/Model/SearchConfig.php:81
 Magento\Setup\Model\SearchConfig->validateSearchEngine() at /var/www/html/mag02/setup/src/Magento/Setup/Model/SearchConfig.php:69
 Magento\Setup\Model\SearchConfig->saveConfiguration() at /var/www/html/mag02/setup/src/Magento/Setup/Model/Installer.php:1197
 Magento\Setup\Model\Installer->installSearchConfiguration() at n/a:n/a
 call_user_func_array() at /var/www/html/mag02/setup/src/Magento/Setup/Model/Installer.php:389
 Magento\Setup\Model\Installer->install() at /var/www/html/mag02/setup/src/Magento/Setup/Console/Command/InstallCommand.php:231
 Magento\Setup\Console\Command\InstallCommand->execute() at /var/www/html/mag02/vendor/symfony/console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at /var/www/html/mag02/vendor/symfony/console/Application.php:1009
 Symfony\Component\Console\Application->doRunCommand() at /var/www/html/mag02/vendor/symfony/console/Application.php:273
 Symfony\Component\Console\Application->doRun() at /var/www/html/mag02/vendor/magento/framework/Console/Cli.php:115
 Magento\Framework\Console\Cli->doRun() at /var/www/html/mag02/vendor/symfony/console/Application.php:149
 Symfony\Component\Console\Application->run() at /var/www/html/mag02/bin/magento:23

 

mag02@3gej:~$ curl -I http://elastic:passwd@127.0.0.1:9229
HTTP/1.1 200 OK
X-elastic-product: Elasticsearch
content-type: application/json; charset=UTF-8
content-length: 533

mag02@3gej:~$ curl  http://elastic:passwd@127.0.0.1:9229
{
  "name" : "3gej",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "wD8OsttjTPmKw0wvHiqCcQ",
  "version" : {
    "number" : "7.14.0",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "dd5a0a2acaa2045ff9624f3729fc8a6f40835aa1",
    "build_date" : "2021-07-29T20:49:32.864135063Z",
    "build_snapshot" : false,
    "lucene_version" : "8.9.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

Re: Could not validate a connection to Elasticsearch. No alive nodes found in your cluster

Interesting findings from my investigation. 

 

tcpdump -i lo -vvv

 

Shows activity when I do a manual curl request, but during the magento installation when it fails, I don't see any activity. Seems the setup isn't making the request to elasticsearch in the way its saying it is. 

Re: Could not validate a connection to Elasticsearch. No alive nodes found in your cluster

Found it, but strange. I noticed that the url had an extra space after the port in the error message. Don't know why that was, so I put quotes around the port in the config param and that worked fine. 

 

 

Re: Could not validate a connection to Elasticsearch. No alive nodes found in your cluster

I have installed Elasticsearch in my Linux Mint & It's working fine. Here is the steps.

Run the below command to Install Elasticsearch In locally.

Download and install the public signing key :

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -

Installing from the APT repositoryedit

You may need to install the apt-transport-https package on Debian before proceeding :

sudo apt-get install apt-transport-https

Save the repository definition to /etc/apt/sources.list.d/elastic-7.x.list :

echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.list

You can install the Elasticsearch Debian package with :

sudo apt-get update && sudo apt-get install elasticsearch

Elasticsearch is not started automatically after installation. How to start and stop Elasticsearch depends on whether your system uses SysV init or systemd (used by newer distributions).

ps -p 1

Running Elasticsearch with SysV init : Use the update-rc.d command to configure Elasticsearch to start automatically when the system boots up :

sudo update-rc.d elasticsearch defaults 95 10

Elasticsearch can be started and stopped using the service command :

sudo -i service elasticsearch start

sudo -i service elasticsearch stop

Configure Apache and Elasticsearch : Set up a proxy (Set up a proxy for Apache 2.4)

Enable mod_proxy as follows :

a2enmod proxy_http or sudo a2enmod proxy_http

Use a text editor to open /etc/apache2/sites-available/000-default.conf

Add the following directive at the top of the file :

Listen 8080

Add the following at the bottom of the file :

<VirtualHost *:8080>
ProxyPass "/" "http://localhost:9200/"
ProxyPassReverse "/" "http://localhost:9200/"
</VirtualHost>

Restart Apache :

service apache2 restart or sudo service apache2 restart

Verify the proxy works by entering the following command :

For example, if your proxy uses port 8080:

curl -i http://localhost:8080/_cluster/health

If curl request success then messages display like below :

HTTP/1.1 200 OK
Date: Sun, 23 Aug 2020 06:05:56 GMT
Server: Apache/2.4.18 (Ubuntu)
content-type: application/json; charset=UTF-8
content-length: 389

{"cluster_name":"elasticsearch","status":"yellow","timed_out":false,"number_of_nodes":1,"number_of_data_nodes":1,"active_primary_shards":1,"active_shards":1,"relocating_shards":0,"initializing_shards":0,"unassigned_shards":1,"delayed_unassigned_shards":0,"number_of_pending_tasks":0,"number_of_in_flight_fetch":0,"task_max_waiting_in_queue_millis":0,"active_shards_percent_as_number":50.0}

Go to Admin Panel -> Stores -> Settings -> Configuration -> Catalog -> Catalog Search. Change the settings like below.

Search Engine : Search Engine7

Elasticsearch Server Hostname : localhost

Elasticsearch Server Port : 8080

Elasticsearch Index Prefix : magento2

Enable Elasticsearch HTTP Auth : No

Elasticsearch Server Timeout : 15

Now save the configuration & run below cache clean command.

php bin/magento cache:clean

Now click on Test Connection button.

After successful you will receive Successful! Test again? in Test Connection button.

Ref : https://devdocs.magento.com/guides/v2.4/install-gde/prereq/es-config-apache.html 
https://www.elastic.co/guide/en/elasticsearch/reference/current/deb.html 

For More 
https://vrajeshpatel.in/2020/08/23/magento-2-4-0-getting-error-could-not-validate-a-connection-to-el... 

Re: Could not validate a connection to Elasticsearch. No alive nodes found in your cluster

I got solution,

in ubuntu, check your elasticsearch status systemctl status elasticsearch, if status is failed, restart your elasticsearch systemctl restart elasticsearch and check status again. If status is active (running), you can try setup:install again.

Re: Could not validate a connection to Elasticsearch. No alive nodes found in your cluster

Hello @fajriarma . Thanks for the help...

 

I'm getting the same error, but when tried your suggestion, it didn't work.

 

When ran the command below,

 

systemctl restart elasticsearch.service

I got the error, "Failed to restart elasticsearch.service: Unit not found."

 

And when I ran the command,

 

systemctl status elasticsearch

I got the error, "Unit elasticsearch.service could not be found."

 

Any suggestions?

 

Thanks

 

 

Re: Could not validate a connection to Elasticsearch. No alive nodes found in your cluster

Hi,
Any Solution for this:

Unit elasticsearch.service could not be found.



Please help.