Introduction

I haven't used Magento a whole lot in my career and this was my first time setting up a Magento website from scratch. After getting all the dependencies setup, including Elasticsearch, I tried to install the application. This is where I was encountering this error:

bash

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

So for the next couple hours I searched for answers. But nothing I tried worked until I came across this answer on Stack Exchange. After following the steps laid out in this answer the installation finally completed without any errors. Here are the steps:

Install the official Magento 2 Elasticsearch 8 Module

bash

composer require magento/module-elasticsearch-8 --with-all-dependencies

Run the install command and disable modules

bash

bin/magento setup:install --disable-modules=Magento_InventoryElasticsearch,Magento_Elasticsearch8,Magento_Elasticsearch,Magento_OpenSearch

Re-enable the modules, except Magento_OpenSearch

bash

bin/magento module:enable Magento_InventoryElasticsearch Magento_Elasticsearch8 Magento_Elasticsearch

Change default search engine to Elasticsearch 8

bash

bin/magento config:set catalog/search/engine 'elasticsearch8'

Start Magento setup

The ElasticSearch 8 service should be running while starting the setup again.

bash

bin/magento setup:upgrade 
bin/magento setup:di:compile

Rerun full install command

After all that, I reran the install command from the Magento docs and it ran without any issues!

bash

bin/magento setup:install \
--base-url=http://localhost/magento2ee \
--db-host=localhost \
--db-name=magento \
--db-user=magento \
--db-password=magento \
--admin-firstname=admin \
--admin-lastname=admin \
--admin-email=admin@admin.com \
--admin-user=admin \
--admin-password=admin123 \
--language=en_US \
--currency=USD \
--timezone=America/Chicago \
--use-rewrites=1 \
--search-engine=elasticsearch \
--elasticsearch-host=127.0.0.1 \
--elasticsearch-port=9200 \
--elasticsearch-index-prefix=magento2 \
--elasticsearch-timeout=15

Final Thoughts

I was pretty close to curling up in a ball and crying before finding Tu Van's answer. So thank you to him!

Was this post helpful?