I have 2 servers, 1 server installed with nginx+php+mysql+Magento2.4.2.

Another elasticsearch 7.13.4 was installed on the server.

I want to connect the magento2 search engine to the elastic search server. How to configure my elasticsearch server,

Does anyone know? Please tell me how to configure it. Thank you very much

  • elasticsearch.yml how to set
    – sq y
    Nov 24, 2022 at 17:30

3 Answers 3


Go to your Magento admin panel Store > Configuration > Catalog > Catalog Search change Elasticsearch Server Hostname value to your Elasticsearch server IP Address as shown in below image:

enter image description here

Click on Test Connection if shown Successfull on Test Connection button than good to go.


Please Run below command

    php -d memory_limit=-1 bin/magento config:set  catalog/search/elasticsearch7_server_hostname (HOSTNAME OR IP ADDRESS)

    php -d memory_limit=-1 bin/magento config:set catalog/search/elasticsearch7_index_prefix  magento2_index (INDEX NAME)

    php -d memory_limit=-1 bin/magento config:set catalog/search/elasticsearch7_enable_auth 1 (MUST BE ONE FOR ENABLE)

    php -d memory_limit=-1 bin/magento config:set catalog/search/elasticsearch7_username  elastic_user (YOUR USER NAME)

    php -d memory_limit=-1 bin/magento config:set catalog/search/elasticsearch7_password  elastic_password (YOUR PASSWORD)

Checked in admin : https://prnt.sc/P2W98B8_YU_B

Stores -> Configuration -> Catalog -> Catalog -> Catalog Search

enter image description here


You can also do using this the command line.

php bin/magento config:set catalog/search/engine elasticsearch7
php bin/magento config:set catalog/search/elasticsearch7_server_hostname localhost
php bin/magento config:set catalog/search/elasticsearch7_server_port 9200

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.