Configure Elasticsearch in the app/etc/env.php
<?php
return [
'system' => [
'default' => [
'catalog' => [
'search' => [
'engine' => 'elasticsearch7', // Change this based on your Elasticsearch version (elasticsearch6, elasticsearch7)
'elasticsearch7_server_hostname' => 'localhost', // Elasticsearch server hostname
'elasticsearch7_server_port' => '9200', // Elasticsearch server port
'elasticsearch7_index_prefix' => 'magento2', // Optional: Prefix for Elasticsearch indexes
'elasticsearch7_enable_auth' => '1', // Set to 1 if authentication is required
'elasticsearch7_server_timeout' => '15', // Connection timeout in seconds
'elasticsearch7_username' => 'your-username', // Elasticsearch username if authentication is required
'elasticsearch7_password' => 'your-password' // Elasticsearch password if authentication is required
]
]
]
]
];
If not in config file then check in in your DB config table for authentication details.
To check if Elasticsearch is enabled on your server. You can verify this by running the following command: