Check the configuration
First let's check if your configuration is correct:
Update your host and port: '[host]:[port]'. E.g.: localhost:9200
in Stores > Settings > Configuration > Catalog > Catalog > Catalog Search or if you are you are using Elastic Suite in Stores > Configuration > ElasticSuit > Basic configuration as per your setting.
Update your indices alias name and indices name pattern in admin configuration same as above.
Clear cache by going to System > Cache Management or using this command (on your server in Magento installation folder):
php bin/magento cache:clean
Reindex by visiting System > Index Management or running command below:
Update catalog search
php bin/magento indexer:reindex catalogsearch_fulltext
Or reindex all indexers
php bin/magento indexer:reindex
Check Elasticsearch
If the error still stands, it might be the issue with the elasticsearch service on your server. To solve this follow the steps below:
Log into your Magento instance.
Check if the elasticsearch is running:
sudo /etc/init.d/elasticsearch status
Try to start it if it's not running, or restart it if it's running:
Start elasticsearch
sudo systemctl start elasticsearch
Or restart elasticsearch
sudo systemctl restart elasticsearch
You've found the issue if you encounter an error here and your elasticsearch doesn't start. Solve the issue first. Continue when the elasticsearch starts.
Navigate to your Magento installation folder
Reindex all indexers
php bin/magento indexer:reindex
Clear the cache
php bin/magento cache:flush
Your problem should have been solved by now.