I have deployed elasticsearch(7.3 version) service on my EC2 instance.
curl localhost:9200
So the solution was simply to modify the following settings in elasticsearch.yml:
elasticsearch.yml
network.host: 0.0.0.0 discovery.type: single-node
Note: The second setting is only necessary if you have a single node.