Connection time out using ES -Hadoop

I am running the application on a VM and ES is running on host OS on localhost:9220 and virtual accesses the host OS on 10.0.2.2.

I specified es.nodes as 10.0.2.2 and es.port as 9220 as ES is running on this address. But the application gives a connection timeout error. What could be the reason?

The full code is available here.