Set up Elasticsearch cluster 2 nodes on same machine

You need to tell the discovery how to discover the other nodes. See https://www.elastic.co/guide/en/elasticsearch/reference/current/discovery-settings.html

Note that it's not really recommended to have multiple nodes per machine unless you have more than 64 gb of physical RAM on your machine.
Is it your case?