Installing Magento 2.4 & Elastic search validation issue

I’ve followed the brilliant tutorial on installing 2.4 exactly as set out by Craig and all was well until the last command…

bin/magento setup:upgrade

It returns the following lines with the last one about Elasticsearch in Red…

Cache cleared successfully
File system cleanup:
/var/www/html/generated/code/Composer
/var/www/html/generated/code/Dotdigitalgroup
/var/www/html/generated/code/Magento
/var/www/html/generated/code/PayPal
/var/www/html/generated/code/Symfony
/var/www/html/generated/code/Yotpo
The directory '/var/www/html/generated/metadata/' doesn't exist - skipping cleanup
/var/www/html/pub/static/deployed_version.txt
/var/www/html/var/view_preprocessed/pub
Updating modules:
Could not validate a connection to Elasticsearch. No alive nodes found in your cluster

Can someone point me in the right direction, please?
I’ll take another look at it tomorrow as I need to leave it now.

I haven’t come across this issue before, but it’s probably safe to assume that your issue is related to one of the following…

Has Elasticsearch hung/crashed?
Verify if the Elasticsearch Service is running with:

sudo systemctl start elasticsearch

If it’s not running, then run:

sudo systemctl start elasticsearch

Is Elasticsearch configured correctly?
You can verify if Elasticsearch is running correctly by running the following test [26:10].

curl -X GET 'http://localhost:9200'

Which should return values similar to:

{
  "name" : "My First Node",
  "cluster_name" : "elasticsearch",
  "version" : {
    "number" : "2.3.1",
    "build_hash" : "bd980929010aef404e7cb0843e61d0665269fc39",
    "build_timestamp" : "2016-04-04T12:25:05Z",
    "build_snapshot" : false,
    "lucene_version" : "5.5.0"
  },
  "tagline" : "You Know, for Search"
}

If not, then revisit Chapter 6, as you may have overlooked something.

That’s strange. I’d tested Elasticsearch earlier in the process yesterday and it was running.
I’ve started the Elasticsearch once again and tested.
Then I’ve gone back into /var/www/html but when I run…
bin/magento cache:clean
I get the warning in Red…

cache_dir "/var/www/html/var/page_cache" is not writable

This wasn’t happening yesterday though.

This message happens when the directory just happens to be written to in that exact moment. Just give it a moment and run again.

In the end, I had to reboot the server.
I tested Elastic search and it was working.
Then went from chapter 9 onwards but it still has the elastic search issue and now I’m stuck at the cmd prompt ‘>’ and I don’t know how to get back to magento@ubuntu-mage2-stylerep:

chris@ubuntu-mage2-stylerep:/var/www/html$ su magento
Password:
magento@ubuntu-mage2-stylerep:/var/www/html$
magento@ubuntu-mage2-stylerep:/var/www/html$ curl -X GET 'http://localhost:9200'
{
  "name" : "Magento Node",
  "cluster_name" : "Magento Cluster",
  "cluster_uuid" : "lRbzzn9iQvSlqlP-y8DrUA",
  "version" : {
    "number" : "7.6.0",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "7f634e9f44834fbc12724506cc1da681b0c3b1e3",
    "build_date" : "2020-02-06T00:09:00.449973Z",
    "build_snapshot" : false,
    "lucene_version" : "8.4.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
magento@ubuntu-mage2-stylerep:/var/www/html$ bin/magento deploy:mode:set developer
Enabled developer mode.
magento@ubuntu-mage2-stylerep:/var/www/html$ rm -rf generated/metadata/* generated/code/*
magento@ubuntu-mage2-stylerep:/var/www/html$ bin/magento cache:clean
Cleaned cache types:
config
layout
block_html
collections
reflection
db_ddl
compiled_config
eav
customer_notification
config_integration
config_integration_api
full_page
config_webservice
translate
vertex
magento@ubuntu-mage2-stylerep:/var/www/html$ bin/magento sampledata:deploy
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
<warning>Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead.</warning>
<warning>Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.</warning>
<warning>Package sebastian/finder-facade is abandoned, you should avoid using it. No replacement was suggested.</warning>
Generating autoload files
81 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
PHP CodeSniffer Config installed_paths set to ../../magento/magento-coding-standard,../../phpcompatibility/php-compatibility
magento@ubuntu-mage2-stylerep:/var/www/html$ bin/magento setup:upgrade
Cache cleared successfully
File system cleanup:
/var/www/html/generated/code/Composer
/var/www/html/generated/code/Dotdigitalgroup
/var/www/html/generated/code/Magento
/var/www/html/generated/code/PayPal
/var/www/html/generated/code/Symfony
/var/www/html/generated/code/Yotpo
The directory '/var/www/html/generated/metadata/' doesn't exist - skipping cleanup
/var/www/html/pub/static/deployed_version.txt
/var/www/html/var/view_preprocessed/pub
Updating modules:
Could not validate a connection to Elasticsearch. No alive nodes found in your cluster
magento@ubuntu-mage2-stylerep:/var/www/html$

All looks good aside from the bit at the end. Did you by chance set any Elasticsearch variables when you ran the Magento Install script originally? I wonder if a typo lead to Magento looking for the wrong port or something.

Went through it all over again, right from the start and still got the ElasticSearch Issue.

magento@ubuntu-mage2-stylerep:/var/www/html$ bin/magento setup:upgrade
Cache cleared successfully
File system cleanup:
/var/www/html/generated/code/Composer
/var/www/html/generated/code/Dotdigitalgroup
/var/www/html/generated/code/Magento
/var/www/html/generated/code/PayPal
/var/www/html/generated/code/Symfony
/var/www/html/generated/code/Yotpo
The directory '/var/www/html/generated/metadata/' doesn't exist - skipping cleanup
/var/www/html/pub/static/deployed_version.txt
/var/www/html/var/view_preprocessed/pub
Updating modules:
Could not validate a connection to Elasticsearch. No alive nodes found in your cluster

magento@ubuntu-mage2-stylerep:/var/www/html$ curl elasticsearch:9200
curl: (6) Could not resolve host: elasticsearch
magento@ubuntu-mage2-stylerep:/var/www/html$ curl -X GET 'http://localhost:9200'
curl: (7) Failed to connect to localhost port 9200: Connection refused

Any thoughts? Has anyone successfully followed the tutorial?

In the following file:

sudo nano /etc/elasticsearch/elasticsearch.yml

What is the current value for network.host? The default is 192.168.0.1. This should be changed to either:

  • localhost or
  • 0.0.0.0

You’ll need to restart elasticsearch for the changes to take affect. I’d suggest trying each value and checking that it runs ok.

It’s set to network.host: localhost

That fixed it for you?

It was already set at network.host: localhost, so It’s still not working.

Tried again but this time with ElasticSearch 7.9.2 and Magento 2.4.1
Everything was fine until’ 9.3 Download Sample Data via Composer’

magento@ubuntu-mage2-stylerep:/var/www/html$ bin/magento sampledata:deploy
<warning>Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2.0 is about to be released and the older 1.x releases will self-update directly to it once it is released. To avoid surprises update now to the latest 1.x version which will prompt you before self-updating to 2.x.</warning>
./composer.json has been updated
Loading composer repositories with package information
<warning>Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2.0 is about to be released and the older 1.x releases will self-update directly to it once it is released. To avoid surprises update now to the latest 1.x version which will prompt you before self-updating to 2.x.</warning>
Updating dependencies (including require-dev)
Killed
magento@ubuntu-mage2-stylerep:/var/www/html$

Any ideas?

I’ve repeated the installation once again from the beginning following your method and versions exactly with the same error message. As it’s the fourth time i’ve followed the instructions faithfully there’s either something wrong with the digital ocean platform or there’s some code that’s not working correctly.

magento@ubuntu-mage2-stylerep:/var/www/html$ bin/magento setup:upgrade
Cache cleared successfully
File system cleanup:
/var/www/html/generated/code/Composer
/var/www/html/generated/code/Dotdigitalgroup
/var/www/html/generated/code/Magento
/var/www/html/generated/code/PayPal
/var/www/html/generated/code/Symfony
/var/www/html/generated/code/Yotpo
The directory '/var/www/html/generated/metadata/' doesn't exist - skipping cleanup
/var/www/html/pub/static/deployed_version.txt
/var/www/html/var/view_preprocessed/pub
Updating modules:
Could not validate a connection to Elasticsearch. No alive nodes found in your cluster
magento@ubuntu-mage2-stylerep:/var/www/html$

Have you any ideas about this Craig?

Sorry, I’ve been unable to reproduce the issue. However, I’ve only tried with Elasticsearch 7.6, Magento 2.4.0 and composer 1.x.

EDIT: Fixed type

Shouldn’t that be Magento 2.4.0 as in the tutorial?

1 Like

sorry to jump on this thread but I am facing the same issue. setup:upgrade gives the no node alive error. even on the Magento admin backend. curl 9200 gives the right response.

my web config is:
Magento 2.4.1
server: Nginx
php-fpm 7.4.3
elastic search 7.6.0

see image.

any solution to this please?

thanks

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.