Magento 2.4.0 - Getting Error Could not validate a connection to Elasticsearch. No alive nodes found in your cluster
I upgraded my Magento 2.3.5 into 2.4.0 and now facing this error, very annoying to say the least,... I fixed it by disabling the Elastic Search module... injecting this into a Magento "update" is totally un-called for, very frustrating and annoying.
After disabling these, my php /bin/magento setup:upgrade works fine now:
php bin/magento module:disable {Magento_Elasticsearch,Magento_InventoryElasticsearch,Magento_Elasticsearch6,Magento_Elasticsearch7}
I thought upgrading into 2.4.0 would make life better, I can't believe there are so many problems just to get into 2.4.0.... don't know what I am walking into, ... I hope my installation that I am about to deploy does not break as a result of so many unwanted modules added into the 2.4.0 update before even trying it yet!...
The issue is the ElasticSearch config in your command.
To start the verification, you can run this curl
command below to validate your ElasticSearch, you can change the host elasticsearch to your host.
curl elasticsearch:9200
These are the issues in your commands:
1º - Don't specify the ElasticSearch host
2º - It's using MySQL which is not supported
3º - It seems to be a generic configuration and not the right one, as your password is changeme
Try this command below.
php -d memory_limit=-1 bin/magento setup:install \
--base-url="http://127.0.0.1/magento240" \
--db-host="127.0.0.1" \
--db-name="magento240" \
--db-user="root" \
--db-password="root123" \
--admin-firstname="admin" \
--admin-lastname="admin" \
--admin-email="[email protected]" \
--admin-user="admin" \
--admin-password="admin123" \
--language="en_US" \
--currency="USD" \
--timezone="America/Chicago" \
--use-rewrites="1" \
--backend-frontname="admin" \
--elasticsearch-host=elasticsearch
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 : Dev Docs & Elasticsearch
For More Click here