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:
- Download Elasticsearch for Windows here: Click Here To Download Elasticsearch here
- unzip archived file at the “C:\xampp\htdocs\” as shown below and go to
\elasticsearch-7.16.2\bin
- Right click on
elasticsearch.bat
and select run as administrator
To check if Elasticsearch is running on your system, in your browser type: localhost: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.
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.