PHPProgramming

Could not validate a connection to elastic search magento

Hey buddy, I hope you are doing well, and you surf over the entire internet to overcome this issue could not validate a connection to elastic search in magento 2.

By looking up at this error message you would understand that the issue is from the elastic search either it is not installed in your system or it is not running. which means we have to skip elastic search while installing magento2.

If you are getting the above error message in your local system you can install the elastic search,

Follow the below step to install elastic search in your window system:

  1. Download Elasticsearch for Windows here: Click Here To Download Elasticsearch here
  2.  unzip archived file at the “C:\xampp\htdocs\” as shown below and go to \elasticsearch-7.16.2\bin
  3. Right click on elasticsearch.bat and select run as administrator
Leave this window running on background

To check if Elasticsearch is running on your system, in your browser typelocalhost:9200

If you see this result page => Elasticsearch is running properly

Now let’s back to the topic, and resolve your issue that could not validate a connection to the elastic search.

To install the magento2 without elastic search on your live server follow the below steps.

First of all, we have to disable the elastic search module on Magento, run the below command to do so.

php bin/magento module:disable {Magento_Elasticsearch,Magento_InventoryElasticsearch,Magento_Elasticsearch6,Magento_Elasticsearch7}

Next, you can run your Magento install command to install your Magento on live server.

php bin/magento setup:install --base-url="your-url" --db-host="localhost" --db-name="magento2" --db-user="root" --db-password="root" --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"

after the successful installation if you have the UI like the below one

then do the below tweaks to fix your UI

Go to: C:\xampp\htdocs\magento2\vendor\magento\framework\View\Element\Template\File

Edit Validator.php using a text editor and find this line:$realPath = $this->fileDriver->getRealPath($path);

Replace with this code:$realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path));

The new file should be like this after editing:

Then, Open up app/etc/di.xml in the editor,

– Find the path “Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink” and replace to “Magento\Framework\App\View\Asset\MaterializationStrategy\Copy

Save the file.

Next, you will need to run these command to upgrade the database and deploy static view files

php bin/magento indexer:reindex
php bin/magento setup:upgrade

then run the below command to deploy it

php bin/magento setup:static-content:deploy -f

Wait for the process to complete. Once done run the below cache command

php bin/magento cache:flush

Now reload your website and you will see your new Magento 2 website on your live server.

magento 2 successfully installed no sample data

I hope you get the solution for could not validate a connection to elastic search has been resovled, still facing issue feel free to comment.

Shaiv Roy

Hy Myself shaiv roy, I am a passionate blogger and love to share ideas among people, I am having good experience with laravel, vue js, react, flutter and doing website and app development work from last 7 years.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button